Reputation: 41740
Because of the limitation of Azure Test Plans not being able to choose a build from a different project, I was wondering if it is possible to create a pipeline that would at least clone the build number from another project.
Here's the narrative:
There's a project
ProjA
with pipelineP1
that generates a build number using the following linename: $(date:yyyyMMdd)$(rev:.r)
I want it such that:
Another project
ProjB
has a pipelineP1
which matches the name inProjA
gets triggered so that there's a build recorded wheneverProjA.P1
is successful and have the build recorded with the same name as the build run fromProjA.P1
UPDATE note I am looking specifically for ProjA.P1
and not whatever would've triggered ProjA.P1
. The original accepted answer works for the simple case where ProjA.P1
is triggered from the ProjA.P1
pipeline.
However, if ProjA.P1
has triggers: none
and uses resources.pipelines
to trigger it's build it uses the build number of the referenced pipeline rather than ProjA.P1
.
Upvotes: 1
Views: 679
Reputation: 30442
We can set a pipeline completion trigger to Trigger one pipeline after another. (ProjB.P1
is triggered when ProjA.P1
completes.)
We can get the trigger build name using the resource variable $(resources.pipeline.<Alias>.runName)
in YAML. (It will retrieve the buildNumber
of the pipeline ProjA.P1
in pipeline.) See Pipeline resource metadata as predefined variables for details.
Then using the UpdateBuildNumber logging command (##vso[build.updatebuildnumber]build number
) to update the build number of the ProjB.P1
.
ProjB.P1
YAML for your reference:
trigger: none
resources:
pipelines:
- pipeline: ProjA-Trigger # Any alias here
source: P1 # The real pipeline name (ProjA.P1 here)
project: ProjA # Project ProjA
trigger:
branches:
include:
- refs/heads/main
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: 'echo "##vso[build.updatebuildnumber]$(resources.pipeline.ProjA-Trigger.runName)"'
Upvotes: 2