Update release-branch-pipeline.yml for Azure Pipelines (#1100)

![](https://media.tenor.com/JHFfBjUQcxEAAAAM/dance-morty.gif)
This commit is contained in:
Mark Iantorno 2023-02-01 11:00:18 -05:00 committed by GitHub
parent e922cc2a97
commit 22dbb5784e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 114 additions and 68 deletions

View File

@ -9,9 +9,15 @@ pool:
variables: variables:
VERSION: VERSION:
jobs:
- job: check_release_notes
timeoutInMinutes: 5
steps: steps:
- task: Bash@3
# Checks if the release notes file is populated. Exits if it is not. # Checks if the release notes file is populated. Exits if it is not.
- bash: | inputs:
targetType: 'inline'
script: |
if [ -n "$(cmp RELEASE_NOTES.md RELEASE_NOTES.template.md)" ] if [ -n "$(cmp RELEASE_NOTES.md RELEASE_NOTES.template.md)" ]
then then
echo "RELEASE_NOTES.md has changed, proceeding to next step" echo "RELEASE_NOTES.md has changed, proceeding to next step"
@ -19,39 +25,78 @@ steps:
echo "Your RELEASE_NOTES.md file is unchanged. Please provide release notes before creating a release." echo "Your RELEASE_NOTES.md file is unchanged. Please provide release notes before creating a release."
exit 1 exit 1
fi fi
displayName: Checks if the release notes file is populated.
# This task pulls the <version> value from the org.hl7.fhir.r5 project pom.xml file. All modules are released as - job: get_release_version
# the same version, at the same time, as defined in the root level pom.xml. timeoutInMinutes: 5
- task: PowerShell@2 steps:
- task: Bash@3
# Prints out the build version, for debugging purposes
inputs: inputs:
targetType: 'inline' targetType: 'inline'
script: | script: |
[xml]$pomXml = Get-Content -Path .\pom.xml echo Pulled version from pom.xml => $(version)
# version displayName: Debug print release version
Write-Host $pomXml.project.version - task: Bash@3
$version=$pomXml.project.version
Write-Host "##vso[task.setvariable variable=version]$version"
# Prints out the build version, for debugging purposes
- bash: echo Pulled version from pom.xml => $(version)
# Azure pipelines cannot pass variables between pipelines, but it can pass files, so we # Azure pipelines cannot pass variables between pipelines, but it can pass files, so we
# pass the build id (ex: 1.1.13-SNAPSHOT) as a string in a file. # pass the build id (ex: 1.1.13-SNAPSHOT) as a string in a file.
# This is used in the release pipeline, so we create it here. # This is used in the release pipeline, so we create it here.
- bash: | inputs:
targetType: 'inline'
script: |
echo $(version) echo $(version)
VERSION=$(version) VERSION=$(version)
echo "$VERSION" > $(System.DefaultWorkingDirectory)/VERSION echo "$VERSION" > $(System.DefaultWorkingDirectory)/VERSION
displayName: Debug print release version
- task: CopyFiles@2
# Copies the VERSION file containing the build id (ex: 1.1.13-SNAPSHOT) to the staging directory # Copies the VERSION file containing the build id (ex: 1.1.13-SNAPSHOT) to the staging directory
# This is done for release versions only. # This is done for release versions only.
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs: inputs:
SourceFolder: '$(System.Defaultworkingdirectory)' SourceFolder: '$(System.Defaultworkingdirectory)'
Contents: "$(System.DefaultWorkingDirectory)/VERSION" Contents: "$(System.DefaultWorkingDirectory)/VERSION"
TargetFolder: '$(build.artifactstagingdirectory)' TargetFolder: '$(build.artifactstagingdirectory)'
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
- job: get_branch_id
timeoutInMinutes: 5
steps:
- task: PowerShell@2
# This task pulls the branch name from the azure build environment and sets as a job-level variable.
inputs:
targetType: 'inline'
script: |
$branch_name = '$(Build.SourceBranchName)'
Write-Host "##vso[task.setvariable variable=branch_name]$branch_name"
displayName: Save branch name to local variable.
- task: Bash@3
# Prints out the branch name, for debugging purposes
inputs:
targetType: 'inline'
script: echo Current branch name => $(branch_name)
displayName: Print out the branch name.
- task: Bash@3
# Azure pipelines cannot pass variables between pipelines, but it can pass files, so we
# pass the branch name (ex: rel_2022_05) as a string in a file.
# This is used in the release pipeline, so we create it here.
inputs:
targetType: 'inline'
script: |
echo $(branch_name)
BRANCH=$(branch_name)
echo "$BRANCH" > $(System.DefaultWorkingDirectory)/BRANCH
displayName: Save branch name to file.
- task: CopyFiles@2
# Copies the BRANCH file containing the pom version to the staging directory
inputs:
SourceFolder: '$(System.Defaultworkingdirectory)'
Contents: "$(System.DefaultWorkingDirectory)/BRANCH"
TargetFolder: '$(build.artifactstagingdirectory)'
displayName: Copy the branch name file to the artifact staging directory.
- job: buildaroni
# We're going to do a full build, including all unit and intergration tests. We do this here, before any
# actual release pipeilne kicks off, and we don't do it again at any point in the release pipeline. The assumption here
# is that once we pull the code, it won't change again on this branch until the release is complete. We
# want to fail fast if there is an issue, and avoid running the tests more than once so it doesn't take all day.
timeoutInMinutes: 360
steps:
# Runs 'mvn clean package' # Runs 'mvn clean package'
- task: Maven@3 - task: Maven@3
inputs: inputs:
@ -63,17 +108,18 @@ steps:
publishJUnitResults: true publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml' testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package' goals: 'package'
- job: publish_build_artifacts
timeoutInMinutes: 5
steps:
# Publishes the built Validator jar to build artifacts. Primarily for testing and debugging builds. # Publishes the built Validator jar to build artifacts. Primarily for testing and debugging builds.
- task: PublishPipelineArtifact@1 - task: PublishPipelineArtifact@1
displayName: 'Publish Validator jar' displayName: 'Publish Validator jar'
inputs: inputs:
targetPath: "$(System.DefaultWorkingDirectory)/org.hl7.fhir.validation/target/org.hl7.fhir.validation-$(version).jar" targetPath: "$(System.DefaultWorkingDirectory)/org.hl7.fhir.validation/target/org.hl7.fhir.validation-$(version).jar"
artifactName: Validator artifactName: Validator
- task: PublishBuildArtifacts@1
# Publishes the files we've moved into the staging directory, so they can be accessed by the # Publishes the files we've moved into the staging directory, so they can be accessed by the
# release pipeline. # release pipeline.
- task: PublishBuildArtifacts@1
displayName: 'Publish Build Artifacts' displayName: 'Publish Build Artifacts'
inputs: inputs:
PathtoPublish: '$(build.artifactstagingdirectory)' PathtoPublish: '$(build.artifactstagingdirectory)'