-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated release pipeline script to create tags for releases off patch branches in the format: 20190730.1-patch1 #382
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,9 @@ fi | |
# Avoid causing cache invalidation with the following check | ||
if [ "$EMBED_BUILDCONTEXT_IN_IMAGES" == "true" ] | ||
then | ||
ctxArgs="--build-arg GIT_COMMIT=$GIT_COMMIT --build-arg BUILD_NUMBER=$BUILD_NUMBER" | ||
ctxArgs="--build-arg GIT_COMMIT=$GIT_COMMIT" | ||
ctxArgs="$ctxArgs --build-arg BUILD_NUMBER=$BUILD_NUMBER" | ||
ctxArgs="$ctxArgs --build-arg RELEASE_TAG_NAME=$RELEASE_TAG_NAME" | ||
echo "Build context args: $ctxArgs" | ||
fi | ||
|
||
|
@@ -80,7 +82,9 @@ function buildDockerImage() { | |
--build-arg AGENTBUILD=$BUILD_SIGNED \ | ||
$BASE_TAG_BUILD_ARGS \ | ||
--build-arg AI_KEY=$APPLICATION_INSIGHTS_INSTRUMENTATION_KEY \ | ||
$ctxArgs -f "$dockerFileToBuild" . | ||
$ctxArgs \ | ||
-f "$dockerFileToBuild" \ | ||
. | ||
|
||
echo | ||
echo Building a base image for tests... | ||
|
@@ -92,7 +96,7 @@ function buildDockerImage() { | |
# Retag build image with build number tags | ||
if [ "$AGENT_BUILD" == "true" ] | ||
then | ||
uniqueTag="$BUILD_DEFINITIONNAME.$BUILD_NUMBER" | ||
uniqueTag="$BUILD_DEFINITIONNAME.$RELEASE_TAG_NAME" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value in release tag name would either just be a build number or buildnumber-patchnumber depending on whether this is a CI build or not and if it is being built in a patch branch or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we add these PR comments as actual comments in the code? They really help understand what is going on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, will do |
||
|
||
echo | ||
echo "Retagging image '$builtImageTag' with ACR related tags..." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,17 +25,21 @@ else | |
echo "Building buildpack runner image..." | ||
fi | ||
|
||
labels="--label com.microsoft.oryx.git-commit=$GIT_COMMIT" | ||
labels="$labels --label com.microsoft.oryx.build-number=$BUILD_NUMBER" | ||
labels="$labels --label com.microsoft.oryx.release-tag-name=$RELEASE_TAG_NAME" | ||
|
||
# Build an image that runs `pack` | ||
echo "-> Building pack runner image: $ACR_PACK_IMAGE_REPO" | ||
echo | ||
cd "$BUILD_IMAGES_BUILD_CONTEXT_DIR" | ||
docker build -f "$PACK_IMAGE_DOCKERFILE" $noCacheFlag \ | ||
--build-arg BUILD_NUMBER="$BUILD_NUMBER" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was not being used |
||
$labels \ | ||
-t $ACR_PACK_IMAGE_REPO:latest \ | ||
. | ||
|
||
if [ "$AGENT_BUILD" == "true" ]; then | ||
BUILD_SUFFIX="$BUILD_DEFINITIONNAME.$BUILD_NUMBER" | ||
BUILD_SUFFIX="$BUILD_DEFINITIONNAME.$RELEASE_TAG_NAME" | ||
|
||
docker tag "$ACR_PACK_IMAGE_REPO:latest" "$ACR_PACK_IMAGE_REPO:$BUILD_SUFFIX" | ||
echo "$ACR_PACK_IMAGE_REPO:$BUILD_SUFFIX" >> $ACR_BUILD_IMAGES_ARTIFACTS_FILE | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,30 @@ variables: | |
- group: Oryx | ||
|
||
stages: | ||
- stage: CreateReleaseTag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idea is to create the release tag name and use it across all stages in the pipeline but it seems ADO does not have a in-built way to pass in data between stages , so here I am writing out the release tag name to an artifact file which will be later read and set as environment variable in other stages. |
||
jobs: | ||
- job: CreateReleaseTag | ||
pool: | ||
name: OryxLinux | ||
variables: | ||
skipComponentGovernanceDetection: true | ||
steps: | ||
- task: ShellScript@2 | ||
inputs: | ||
scriptPath: ./vsts/scripts/createReleaseTag.sh | ||
displayName: 'Create release tag' | ||
- script: | | ||
set -ex | ||
sourcesArtifactsDir="$(Build.SourcesDirectory)/artifacts" | ||
mkdir -p "$sourcesArtifactsDir" | ||
echo "$(RELEASE_TAG_NAME)" > "$sourcesArtifactsDir/releaseTag.txt" | ||
displayName: 'Write release tag name to an artifact file' | ||
- task: PublishPipelineArtifact@1 | ||
displayName: 'Publish artifact file having the release tag name' | ||
inputs: | ||
targetPath: $(Build.SourcesDirectory)/artifacts/releaseTag.txt | ||
artifactName: releaseTag | ||
|
||
- stage: Build | ||
displayName: Build Stage | ||
jobs: | ||
|
@@ -27,6 +51,19 @@ stages: | |
SignType: 'test' | ||
skipComponentGovernanceDetection: true | ||
steps: | ||
- task: DownloadPipelineArtifact@2 | ||
displayName: 'Download artifact file having release tag name' | ||
inputs: | ||
targetPath: $(Build.SourcesDirectory)/artifacts/releaseTag | ||
artifactName: 'releaseTag' | ||
- powershell: | | ||
$file = "$env:BUILD_SOURCESDIRECTORY\artifacts\releaseTag\releaseTag.txt" | ||
if (Test-Path $file) { | ||
$tagName = [IO.File]::ReadAllText($file) | ||
Write-Host "Content is $tagName" | ||
echo "##vso[task.setvariable variable=RELEASE_TAG_NAME;]$tagName" | ||
} | ||
displayName: 'Set release tag name as environment variable' | ||
- template: templates/_signBinary.yml | ||
|
||
- job: Job_BuildImage | ||
|
@@ -50,6 +87,8 @@ stages: | |
echo "##vso[task.setvariable variable=EmbedBuildContextInImages;]true" | ||
displayName: 'Set variables' | ||
|
||
- template: templates/_setReleaseTag.yml | ||
|
||
- template: templates/_buildTemplate.yml | ||
|
||
- job: Job_RuntimeImages | ||
|
@@ -73,6 +112,8 @@ stages: | |
echo "##vso[task.setvariable variable=EmbedBuildContextInImages;]true" | ||
displayName: 'Set variables' | ||
|
||
- template: templates/_setReleaseTag.yml | ||
|
||
- template: templates/_buildTemplate.yml | ||
|
||
- template: templates/_integrationJobTemplate.yml | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
steps: | ||
- task: DownloadPipelineArtifact@2 | ||
displayName: 'Download artifact file having release tag name' | ||
inputs: | ||
targetPath: $(Build.SourcesDirectory)/artifacts/releaseTag | ||
artifactName: 'releaseTag' | ||
|
||
- script: | | ||
set -e | ||
file="$(Build.SourcesDirectory)/artifacts/releaseTag/releaseTag.txt" | ||
echo "Release tag name is:" | ||
cat "$file" | ||
tagName="" | ||
if [ -f "$file" ]; then | ||
tagName=`cat $file` | ||
fi | ||
echo "##vso[task.setvariable variable=RELEASE_TAG_NAME;]$tagName" | ||
displayName: 'Read release tag name from artifact file and set it as environment variable' | ||
name: setReleaseTag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for non-CI builds we would default to build number as usual