Skip to content

Commit

Permalink
[docker-ptf]: CI change to publish docker-ptf image to the docker reg…
Browse files Browse the repository at this point in the history
…istry (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
  • Loading branch information
opcoder0 authored and mssonicbld committed Oct 31, 2024
1 parent a3f3a25 commit 254035e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion .azure-pipelines/azure-pipelines-image-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,28 @@ jobs:
displayName: 'Make configure'
postSteps:
- script: |
BUILD_REASON=$(Build.Reason)
echo "Build.Reason = $BUILD_REASON"
echo "Build.DefinitionName = $BUILD_DEFINITIONNAME"
if [[ "$BUILD_REASON" != "PullRequest" && "$BUILD_DEFINITIONNAME" == "Azure.sonic-buildimage.official.vs" ]]
then
PORT=443
DOCKERS=$(ls target/docker-ptf.gz)
BRANCH=$(Build.SourceBranchName)
echo "Branch = $BRANCH"
LABELS="$BRANCH"
[[ "$BRANCH" == "master" ]] && LABELS="$LABELS latest"
for f in $DOCKERS; do
echo $f
echo "Labels = $LABELS"
./push_docker.sh $f $(REGISTRY_SERVER_PUBLIC) $PORT $(REGISTRY_USERNAME) "$REGISTRY_PASSWD" "$LABELS"
done
fi
mkdir -p $(Build.ArtifactStagingDirectory)/target
mv target/* $(Build.ArtifactStagingDirectory)/target/
displayName: Copy Artifacts
env:
REGISTRY_PASSWD: $(REGISTRY_PASSWD)
displayName: Publish to Docker Registry and Copy Artifacts
condition: always()
- publish: $(Build.ArtifactStagingDirectory)
artifact: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)'
Expand Down
1 change: 1 addition & 0 deletions .azure-pipelines/official-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ stages:
- stage: Build
pool: sonicbld-1es
variables:
- group: Container-Registry
- name: CACHE_MODE
value: wcache
- template: .azure-pipelines/azure-pipelines-repd-build-variables.yml@buildimage
Expand Down

0 comments on commit 254035e

Please sign in to comment.