diff --git a/vsts/pipelines/templates/_releaseStepTemplate.yml b/vsts/pipelines/templates/_releaseStepTemplate.yml index ec02e8a098..c4c6d81692 100644 --- a/vsts/pipelines/templates/_releaseStepTemplate.yml +++ b/vsts/pipelines/templates/_releaseStepTemplate.yml @@ -53,7 +53,7 @@ steps: displayName: 'Pull and create release tags for buildpack images' inputs: type: FilePath - scriptPath: ./vsts/scripts/create-releasetags-buildpacks.sh + scriptPath: ./vsts/scripts/tagBuildpacksImagesForRelease.sh condition: and(succeeded(), eq(variables['ReleaseBuildImages'], 'true')) - task: Docker@0 diff --git a/vsts/scripts/tagBuildImagesForRelease.sh b/vsts/scripts/tagBuildImagesForRelease.sh index a2ea9c0132..2e088cc583 100644 --- a/vsts/scripts/tagBuildImagesForRelease.sh +++ b/vsts/scripts/tagBuildImagesForRelease.sh @@ -8,6 +8,7 @@ set -o pipefail sourceImageName="oryxdevmcr.azurecr.io/public/oryx/build" buildNumber=$BUILD_BUILDNUMBER +sourceBranchName=$BUILD_SOURCEBRANCHNAME sourceImage="$sourceImageName:Oryx-CI.$buildNumber" outFileMCR="$BUILD_ARTIFACTSTAGINGDIRECTORY/drop/images/build-images-mcr.txt" outFileDocker="$BUILD_ARTIFACTSTAGINGDIRECTORY/drop/images/build-images-dockerhub.txt" @@ -26,15 +27,22 @@ dockerHubSpecific="$dockerHubRepoName:$buildNumber" echo echo "Tagging the source image with tag $acrSpecific..." echo "$acrSpecific">>"$outFileMCR" -docker tag "$sourceImage" "$acrSpecific" -echo "Tagging the source image with tag $acrLatest..." -echo "$acrLatest">>"$outFileMCR" -docker tag "$sourceImage" "$acrLatest" - -echo "Tagging the source image with tag $dockerHubLatest..." -echo "$dockerHubLatest">>"$outFileDocker" -docker tag "$sourceImage" "$dockerHubLatest" +docker tag "$sourceImage" "$acrSpecific" + echo "Tagging the source image with tag $dockerHubSpecific..." echo "$dockerHubSpecific">>"$outFileDocker" docker tag "$sourceImage" "$dockerHubSpecific" + +if [ "$sourceBranchName" == "master" ]; then + echo "Tagging the source image with tag $acrLatest..." + echo "$acrLatest">>"$outFileMCR" + docker tag "$sourceImage" "$acrLatest" + + echo "Tagging the source image with tag $dockerHubLatest..." + echo "$dockerHubLatest">>"$outFileDocker" + docker tag "$sourceImage" "$dockerHubLatest" +else + echo "Not creating 'latest' tag as source branch is not 'master'. Current branch is $sourceBranchName" +fi + echo ------------------------------------------------------------------------------- \ No newline at end of file diff --git a/vsts/scripts/create-releasetags-buildpacks.sh b/vsts/scripts/tagBuildpacksImagesForRelease.sh similarity index 54% rename from vsts/scripts/create-releasetags-buildpacks.sh rename to vsts/scripts/tagBuildpacksImagesForRelease.sh index e726490d0d..805d0e7d6d 100644 --- a/vsts/scripts/create-releasetags-buildpacks.sh +++ b/vsts/scripts/tagBuildpacksImagesForRelease.sh @@ -11,27 +11,41 @@ declare -r sourceImageRepo="oryxdevmcr.azurecr.io/public/oryx" declare -r prodImageRepo="oryxmcr.azurecr.io/public/oryx" buildNumber=$BUILD_BUILDNUMBER +sourceBranchName=$BUILD_SOURCEBRANCHNAME -echo "Pulling pack-builder image and retagging with 'stable' and 'builderNumber'..." +echo "Pulling pack-builder image..." packBuilderImage=$sourceImageRepo/pack-builder:Oryx-CI.$buildNumber docker pull "$packBuilderImage" -echo "$prodImageRepo/pack-builder:stable">>"$outFile" +echo "Retagging pack-builder image 'builderNumber'..." echo "$prodImageRepo/pack-builder:$buildNumber">>"$outFile" -docker tag "$packBuilderImage" "$prodImageRepo/pack-builder:stable" docker tag "$packBuilderImage" "$prodImageRepo/pack-builder:$buildNumber" -echo "Pulling pack-stack-base image and retagging with 'latest' and 'builderNumber'..." +echo "Pulling pack-stack-base..." packStackBaseImage=$sourceImageRepo/pack-stack-base:Oryx-CI.$buildNumber docker pull "$packStackBaseImage" -echo "$prodImageRepo/pack-stack-base:latest">>"$outFile" +echo "Retagging pack-stack-base image 'builderNumber'..." echo "$prodImageRepo/pack-stack-base:$buildNumber">>"$outFile" -docker tag "$packStackBaseImage" "$prodImageRepo/pack-stack-base:latest" docker tag "$packStackBaseImage" "$prodImageRepo/pack-stack-base:$buildNumber" -echo "Pulling pack image and retagging with 'stable' and 'builderNumber'..." +echo "Pulling pack image..." packImage=$sourceImageRepo/pack:Oryx-CI.$buildNumber docker pull "$packImage" -echo "$prodImageRepo/pack:stable">>"$outFile" +echo "Retagging pack image with 'builderNumber'..." echo "$prodImageRepo/pack:$buildNumber">>"$outFile" -docker tag "$packImage" "$prodImageRepo/pack:stable" docker tag "$packImage" "$prodImageRepo/pack:$buildNumber" + +if [ "$sourceBranchName" == "master" ]; then + echo "Retagging pack-builder image with 'stable'..." + docker tag "$packBuilderImage" "$prodImageRepo/pack-builder:stable" + echo "$prodImageRepo/pack-builder:stable">>"$outFile" + + echo "Retagging pack-stack-base image with 'latest'..." + docker tag "$packStackBaseImage" "$prodImageRepo/pack-stack-base:latest" + echo "$prodImageRepo/pack-stack-base:latest">>"$outFile" + + echo "Retagging pack image with 'stable'..." + docker tag "$packImage" "$prodImageRepo/pack:stable" + echo "$prodImageRepo/pack:stable">>"$outFile" +else + echo "Not creating 'stable' or 'latest' tags as source branch is not 'master'. Current branch is $sourceBranchName" +fi \ No newline at end of file diff --git a/vsts/scripts/tagRunTimeImagesForRelease.sh b/vsts/scripts/tagRunTimeImagesForRelease.sh index 559a749487..97a64d6b68 100644 --- a/vsts/scripts/tagRunTimeImagesForRelease.sh +++ b/vsts/scripts/tagRunTimeImagesForRelease.sh @@ -6,6 +6,7 @@ set -o pipefail +sourceBranchName=$BUILD_SOURCEBRANCHNAME outFileMCR="$BUILD_ARTIFACTSTAGINGDIRECTORY/drop/images/runtime-images-mcr.txt" outFileDocker="$BUILD_ARTIFACTSTAGINGDIRECTORY/drop/images/runtime-images-dockerhub.txt" sourceFile="$BUILD_ARTIFACTSTAGINGDIRECTORY/drop/images/runtime-images-acr.txt" @@ -46,16 +47,22 @@ while read sourceImage; do echo "Tagging the source image with tag $acrSpecific..." echo "$acrSpecific">>"$outFileMCR" docker tag "$sourceImage" "$acrSpecific" - echo "Tagging the source image with tag $acrLatest..." - echo "$acrLatest">>"$outFileMCR" - docker tag "$sourceImage" "$acrLatest" - echo "Tagging the source image with tag $dockerHubLatest..." - echo "$dockerHubLatest">>"$outFileDocker" - docker tag "$sourceImage" "$dockerHubLatest" echo "Tagging the source image with tag $dockerHubSpecific..." echo "$dockerHubSpecific">>"$outFileDocker" docker tag "$sourceImage" "$dockerHubSpecific" + + if [ "$sourceBranchName" == "master" ]; then + echo "Tagging the source image with tag $acrLatest..." + echo "$acrLatest">>"$outFileMCR" + docker tag "$sourceImage" "$acrLatest" + + echo "Tagging the source image with tag $dockerHubLatest..." + echo "$dockerHubLatest">>"$outFileDocker" + docker tag "$sourceImage" "$dockerHubLatest" + else + echo "Not creating 'latest' tag as source branch is not 'master'. Current branch is $sourceBranchName" + fi echo ------------------------------------------------------------------------------- fi done <"$sourceFile" \ No newline at end of file