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,71 +9,117 @@ pool:
variables: variables:
VERSION: VERSION:
steps: jobs:
# Checks if the release notes file is populated. Exits if it is not. - job: check_release_notes
- bash: | timeoutInMinutes: 5
if [ -n "$(cmp RELEASE_NOTES.md RELEASE_NOTES.template.md)" ] steps:
then - task: Bash@3
echo "RELEASE_NOTES.md has changed, proceeding to next step" # Checks if the release notes file is populated. Exits if it is not.
else inputs:
echo "Your RELEASE_NOTES.md file is unchanged. Please provide release notes before creating a release." targetType: 'inline'
exit 1 script: |
fi if [ -n "$(cmp RELEASE_NOTES.md RELEASE_NOTES.template.md)" ]
then
# This task pulls the <version> value from the org.hl7.fhir.r5 project pom.xml file. All modules are released as echo "RELEASE_NOTES.md has changed, proceeding to next step"
# the same version, at the same time, as defined in the root level pom.xml. else
- task: PowerShell@2 echo "Your RELEASE_NOTES.md file is unchanged. Please provide release notes before creating a release."
inputs: exit 1
targetType: 'inline' fi
script: | displayName: Checks if the release notes file is populated.
[xml]$pomXml = Get-Content -Path .\pom.xml - job: get_release_version
# version timeoutInMinutes: 5
Write-Host $pomXml.project.version steps:
$version=$pomXml.project.version - task: Bash@3
Write-Host "##vso[task.setvariable variable=version]$version" # Prints out the build version, for debugging purposes
inputs:
# Prints out the build version, for debugging purposes targetType: 'inline'
- bash: echo Pulled version from pom.xml => $(version) script: |
echo Pulled version from pom.xml => $(version)
# Azure pipelines cannot pass variables between pipelines, but it can pass files, so we displayName: Debug print release version
# pass the build id (ex: 1.1.13-SNAPSHOT) as a string in a file. - task: Bash@3
# This is used in the release pipeline, so we create it here. # Azure pipelines cannot pass variables between pipelines, but it can pass files, so we
- bash: | # pass the build id (ex: 1.1.13-SNAPSHOT) as a string in a file.
echo $(version) # This is used in the release pipeline, so we create it here.
VERSION=$(version) inputs:
echo "$VERSION" > $(System.DefaultWorkingDirectory)/VERSION targetType: 'inline'
script: |
# Copies the VERSION file containing the build id (ex: 1.1.13-SNAPSHOT) to the staging directory echo $(version)
# This is done for release versions only. VERSION=$(version)
- task: CopyFiles@2 echo "$VERSION" > $(System.DefaultWorkingDirectory)/VERSION
displayName: 'Copy Files to: $(build.artifactstagingdirectory)' displayName: Debug print release version
inputs: - task: CopyFiles@2
SourceFolder: '$(System.Defaultworkingdirectory)' # Copies the VERSION file containing the build id (ex: 1.1.13-SNAPSHOT) to the staging directory
Contents: "$(System.DefaultWorkingDirectory)/VERSION" # This is done for release versions only.
TargetFolder: '$(build.artifactstagingdirectory)' inputs:
SourceFolder: '$(System.Defaultworkingdirectory)'
# Runs 'mvn clean package' Contents: "$(System.DefaultWorkingDirectory)/VERSION"
- task: Maven@3 TargetFolder: '$(build.artifactstagingdirectory)'
inputs: displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
mavenPomFile: 'pom.xml' - job: get_branch_id
mavenOptions: '-Xmx3072m' timeoutInMinutes: 5
javaHomeOption: 'JDKVersion' steps:
jdkVersionOption: '1.11' - task: PowerShell@2
jdkArchitectureOption: 'x64' # This task pulls the branch name from the azure build environment and sets as a job-level variable.
publishJUnitResults: true inputs:
testResultsFiles: '**/surefire-reports/TEST-*.xml' targetType: 'inline'
goals: 'package' script: |
$branch_name = '$(Build.SourceBranchName)'
# Publishes the built Validator jar to build artifacts. Primarily for testing and debugging builds. Write-Host "##vso[task.setvariable variable=branch_name]$branch_name"
- task: PublishPipelineArtifact@1 displayName: Save branch name to local variable.
displayName: 'Publish Validator jar' - task: Bash@3
inputs: # Prints out the branch name, for debugging purposes
targetPath: "$(System.DefaultWorkingDirectory)/org.hl7.fhir.validation/target/org.hl7.fhir.validation-$(version).jar" inputs:
artifactName: Validator targetType: 'inline'
script: echo Current branch name => $(branch_name)
# Publishes the files we've moved into the staging directory, so they can be accessed by the displayName: Print out the branch name.
# release pipeline. - task: Bash@3
- task: PublishBuildArtifacts@1 # Azure pipelines cannot pass variables between pipelines, but it can pass files, so we
displayName: 'Publish Build Artifacts' # pass the branch name (ex: rel_2022_05) as a string in a file.
inputs: # This is used in the release pipeline, so we create it here.
PathtoPublish: '$(build.artifactstagingdirectory)' 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'
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
- job: publish_build_artifacts
timeoutInMinutes: 5
steps:
# Publishes the built Validator jar to build artifacts. Primarily for testing and debugging builds.
- task: PublishPipelineArtifact@1
displayName: 'Publish Validator jar'
inputs:
targetPath: "$(System.DefaultWorkingDirectory)/org.hl7.fhir.validation/target/org.hl7.fhir.validation-$(version).jar"
artifactName: Validator
- task: PublishBuildArtifacts@1
# Publishes the files we've moved into the staging directory, so they can be accessed by the
# release pipeline.
displayName: 'Publish Build Artifacts'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'