From 93b714bcb39dae27bddb1cdff6cec4aa31fc110f Mon Sep 17 00:00:00 2001 From: mikeandescavage <58749836+mikeandescavage@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:05:09 -0700 Subject: [PATCH] Update OB Build Pipeline to Pass Build Tag as Var (#2011) * adding release_tag functionality to support releasing by tag or commit --- .../onebranch/pipeline.buildrp.official.yml | 29 ++++++++++--------- .../pipeline.buildrp.pullrequest.yml | 29 ++++++++++--------- .../templates/template-buildrp-buildaro.yml | 11 +++++++ .../template-buildrp-builddocker.yml | 2 +- 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/.pipelines/onebranch/pipeline.buildrp.official.yml b/.pipelines/onebranch/pipeline.buildrp.official.yml index 7245dee49..922dfa4c6 100644 --- a/.pipelines/onebranch/pipeline.buildrp.official.yml +++ b/.pipelines/onebranch/pipeline.buildrp.official.yml @@ -47,20 +47,6 @@ extends: suppressionSet: default stages: - - stage: Build_Docker_Image - jobs: - - job: Build_Docker_Image - pool: - type: docker - os: linux - - variables: - ob_git_checkout: true - - steps: - - template: .pipelines/onebranch/templates/template-buildrp-builddocker.yml@self - - - stage: Build_ARO jobs: - job: Build_ARO @@ -72,3 +58,18 @@ extends: steps: - template: .pipelines/onebranch/templates/template-buildrp-buildaro.yml@self + + - stage: Build_Docker_Image + dependsOn: Build_ARO + jobs: + - job: Build_Docker_Image + pool: + type: docker + os: linux + + variables: + ob_git_checkout: true + release_tag: $[stageDependencies.Build_ARO.Build_ARO.outputs['buildaro.releasetag']] + + steps: + - template: .pipelines/onebranch/templates/template-buildrp-builddocker.yml@self diff --git a/.pipelines/onebranch/pipeline.buildrp.pullrequest.yml b/.pipelines/onebranch/pipeline.buildrp.pullrequest.yml index 8ddd20686..19e13ad96 100644 --- a/.pipelines/onebranch/pipeline.buildrp.pullrequest.yml +++ b/.pipelines/onebranch/pipeline.buildrp.pullrequest.yml @@ -47,20 +47,6 @@ extends: suppressionSet: default stages: - - stage: Build_Docker_Image - jobs: - - job: Build_Docker_Image - pool: - type: docker - os: linux - - variables: - ob_git_checkout: true - - steps: - - template: .pipelines/onebranch/templates/template-buildrp-builddocker.yml@self - - - stage: Build_ARO jobs: - job: Build_ARO @@ -72,3 +58,18 @@ extends: steps: - template: .pipelines/onebranch/templates/template-buildrp-buildaro.yml@self + + - stage: Build_Docker_Image + dependsOn: Build_ARO + jobs: + - job: Build_Docker_Image + pool: + type: docker + os: linux + + variables: + ob_git_checkout: true + release_tag: $[stageDependencies.Build_ARO.Build_ARO.outputs['buildaro.releasetag']] + + steps: + - template: .pipelines/onebranch/templates/template-buildrp-builddocker.yml@self diff --git a/.pipelines/onebranch/templates/template-buildrp-buildaro.yml b/.pipelines/onebranch/templates/template-buildrp-buildaro.yml index 5cd189146..941d020f6 100644 --- a/.pipelines/onebranch/templates/template-buildrp-buildaro.yml +++ b/.pipelines/onebranch/templates/template-buildrp-buildaro.yml @@ -5,6 +5,16 @@ steps: targetType: inline script: | export GOPATH=$(Agent.TempDirectory) + export TAG=$(git describe --exact-match 2>/dev/null) + export COMMIT=$(git rev-parse --short=7 HEAD)$([[ $(git status --porcelain) = "" ]] || echo -dirty) + if [ -z "$TAG" ]; + then + export VERSION=${COMMIT} + else + export VERSION=${TAG} + fi + echo "Version: ${VERSION}" + echo "##vso[task.setvariable variable=releasetag;isOutput=true]${VERSION}" mkdir -p $(Agent.TempDirectory)/src/github.com/Azure/ cp -rd $(Build.SourcesDirectory) $(Agent.TempDirectory)/src/github.com/Azure/ARO-RP cd $(Agent.TempDirectory)/src/github.com/Azure/ARO-RP @@ -12,6 +22,7 @@ steps: mkdir -p $(ob_outputDirectory) cp aro $(ob_outputDirectory)/aro workingDirectory: $(Build.SourcesDirectory) + name: buildaro - task: Bash@3 displayName: 🕵️ Validate FIPS inputs: diff --git a/.pipelines/onebranch/templates/template-buildrp-builddocker.yml b/.pipelines/onebranch/templates/template-buildrp-builddocker.yml index 5ec9414e5..867edc356 100644 --- a/.pipelines/onebranch/templates/template-buildrp-builddocker.yml +++ b/.pipelines/onebranch/templates/template-buildrp-builddocker.yml @@ -9,4 +9,4 @@ steps: saveImageToPath: aro-rp.tar buildkit: 1 enable_network: true - build_tag: $(Build.SourceBranchName) + build_tag: $(release_tag)