Skip to content

Commit c03ae8d

Browse files
authored
[docker-ptf]: CI change to publish docker-ptf image to the docker registry (sonic-net#20528)
Why I did it Changes to docker-ptf Dockerfile don't get automatically published to the docker registry accessed by the community. This PR addresses the issue. Work item tracking Microsoft ADO (number only): 29869315 How I did it Modified the postSteps phase in azure-pipelines-image-template.yml to invoke the script to push docker-ptf image to the docker registry. The push is applicable to build branches (master, 202305, 202311 etc.) and not feature branches. How to verify it TBD Tested branch (Please provide the tested image version) Not applicable. Description for the changelog [docker-ptf]: CI change to publish docker-ptf image to the public/community docker registry Change pipeline YAML to publish docker-ptf image to docker registry Publish only docker-ptf image for main or release branches only and not feature branch Link to config_db schema for YANG module changes Not applicable
1 parent 0e419bb commit c03ae8d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

.azure-pipelines/azure-pipelines-image-template.yml

+20-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,28 @@ jobs:
5858
displayName: 'Make configure'
5959
postSteps:
6060
- script: |
61+
BUILD_REASON=$(Build.Reason)
62+
echo "Build.Reason = $BUILD_REASON"
63+
echo "Build.DefinitionName = $BUILD_DEFINITIONNAME"
64+
if [[ "$BUILD_REASON" != "PullRequest" && "$BUILD_DEFINITIONNAME" == "Azure.sonic-buildimage.official.vs" ]]
65+
then
66+
PORT=443
67+
DOCKERS=$(ls target/docker-ptf.gz)
68+
BRANCH=$(Build.SourceBranchName)
69+
echo "Branch = $BRANCH"
70+
LABELS="$BRANCH"
71+
[[ "$BRANCH" == "master" ]] && LABELS="$LABELS latest"
72+
for f in $DOCKERS; do
73+
echo $f
74+
echo "Labels = $LABELS"
75+
./push_docker.sh $f $(REGISTRY_SERVER_PUBLIC) $PORT $(REGISTRY_USERNAME) "$REGISTRY_PASSWD" "$LABELS"
76+
done
77+
fi
6178
mkdir -p $(Build.ArtifactStagingDirectory)/target
6279
mv target/* $(Build.ArtifactStagingDirectory)/target/
63-
displayName: Copy Artifacts
80+
env:
81+
REGISTRY_PASSWD: $(REGISTRY_PASSWD)
82+
displayName: Publish to Docker Registry and Copy Artifacts
6483
condition: always()
6584
- publish: $(Build.ArtifactStagingDirectory)
6685
artifact: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)'

.azure-pipelines/official-build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ stages:
3636
- stage: Build
3737
pool: sonicbld-1es
3838
variables:
39+
- group: Container-Registry
3940
- name: CACHE_MODE
4041
value: wcache
4142
- template: .azure-pipelines/azure-pipelines-repd-build-variables.yml@buildimage

0 commit comments

Comments
 (0)