In the classic release pipeline it was possible to add other pipelines as Artifact resources - these could be triggers, or just references. You could then reference information about them, e.g. the build id using $(Release.Artifacts.ARTIFACTNAME.BuildId)
.
You can now do something similar in a multi-stage yaml pipeline:
resources:
pipelines:
- pipeline: MyBuild
source: My build pipeline name
trigger:
branches:
- master
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: Write-Host Referenced pipeline build id is: ???
But as per the PowerShell step above, I can't find a way to get the build id of a resource associated in this way, and I can't spot anything in the documentation yet.
Some desperate attempts I've made are:
$(Release.Artifacts.MyBuild.BuildId)
$(resources.MyBuild.BuildId)
$(BuildId@MyBuild)
Does anyone know how this can be done?
Go to the target pipeline you want -> Edit. Check the URL. There you have the pipeline id.
Build numbers in Azure DevOps In Azure DevOps, build numbers may be in a format that doesn't represent a valid SemVer number. For example, Microsoft's Build Number format documentation gives an example: $(TeamProject)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.
Build. BuildId - The ID of the record for the completed build. Build. BuildNumber - The name of the completed build, also known as the run number and that it can be customized.
Use $(Rev:r) to ensure that every completed build has a unique name. When a build starts, if nothing else in the build number has changed, the Rev integer value is incremented by one.
The newest release notes has a new set of predefined variables.
resources.pipeline.{Alias}.projectName
resources.pipeline.{Alias}.projectID
resources.pipeline.{Alias}.pipelineName
resources.pipeline.{Alias}.pipelineID
resources.pipeline.{Alias}.runName
resources.pipeline.{Alias}.runID
resources.pipeline.{Alias}.runURI
resources.pipeline.{Alias}.sourceBranch
resources.pipeline.{Alias}.sourceCommit
resources.pipeline.{Alias}.sourceProvider
resources.pipeline.{Alias}.requestedFor
resources.pipeline.{Alias}.requestedForID
See here https://docs.microsoft.com/en-us/azure/devops/release-notes/2019/sprint-160-update#pipeline-resource-meta-data-as-predefined-variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With