Skip to content

Commit

Permalink
Use 'latest' tag only for images produced out of master branch builds (
Browse files Browse the repository at this point in the history
  • Loading branch information
kichalla authored Jun 28, 2019
1 parent d8a3886 commit 7adf371
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 24 deletions.
2 changes: 1 addition & 1 deletion vsts/pipelines/templates/_releaseStepTemplate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 16 additions & 8 deletions vsts/scripts/tagBuildImagesForRelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 -------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 13 additions & 6 deletions vsts/scripts/tagRunTimeImagesForRelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

0 comments on commit 7adf371

Please sign in to comment.