I am building a .NET application in Azure DevOps, setting its version using GitVersion through Cake script, and then build it. It appears to get the Build number from this value created in GitVersion. I want the informational build number to populate part of my name. I am using the designer but for ease of use, here is the YAML file of the publish artifact step:
#Your build pipeline references the ‘deployment.PPILDeployDirectory’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘deployment.integration.environment’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
steps:
- task: PublishBuildArtifacts@1
displayName: 'Publish Integration Artifact copy'
inputs:
PathtoPublish: '$(deployment.PPILDeployDirectory)'
ArtifactName: '$(deployment.integration.environment)_integration_drop'
How do I suffix my ArtifactName with the informational build number (which includes the branch and build information)? What is the variable I need to grab? Are there any other variables related to build numbers that I should be aware of?
How do I suffix my ArtifactName with the informational build number (which includes the branch and build information)?
You can use the variables $(Build.BuildNumber)
and $(Build.SourceBranchName)
as suffix of your ArtifactName, like:
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: dist'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Test_$(Build.BuildNumber)_$(Build.SourceBranchName)'
After build, we could to see log under the summary tab, build number is 20190425.7
and source branch is master
.
The list of available variables is found at:
Hope this helps.