Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the latest build id from a referenced pipeline resource

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?

like image 999
Mike Goatly Avatar asked Nov 07 '19 11:11

Mike Goatly


People also ask

How do you find the ID of a build pipeline?

Go to the target pipeline you want -> Edit. Check the URL. There you have the pipeline id.

How do I find my build number in Azure DevOps?

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:.

What is build BuildId?

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.

What is $( Rev R?

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.


1 Answers

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

like image 116
JohannesH Avatar answered Sep 20 '22 11:09

JohannesH