I am following this documentation pipeline trigger one after another and configured the triggering pipeline as below to the main.Please note that all the below .yaml configuration are available in master branch.
I am referring testsign as pipeline A here:
Pipeline B:
resources:
pipelines:
- pipeline: test
source: testsign #source pipeline
trigger:
branches:
include:
- master
- user/*
The changes are working as expected when I triggered any feature branch source pipeline manually followed by automatic build of the triggering pipeline.
Now, I went further to configure the same for every PR. so, that 1st pipeline runs build & second runs the tests on hosted agents using the source pipeline artifacts.
For this, I set up the branch policy of Master branch to run source pipeline(testsign) automatically for every PR, assuming that pipeline B will be triggered after completion of A. While it successfully triggered pipeline A, but pipeline B never triggered.
I also, went with another approach adding the PR trigger in pipeline B.But, it did not work either.
trigger: none
pr:
branches:
include:
- master
- user/*
resources:
pipelines:
- pipeline: test
source: testsign
trigger:
branches:
include:
- master
- user/*
Is it actually possible to use resource pipeline trigger for every PR? if yes, please let me know, if there is any misconfiguration I made here. Thanks!
You can include
the branches refs/pull/*
as part of the pipeline resource trigger
in Pipeline B.
resources:
pipelines:
- pipeline: test
source: testsign
trigger:
branches:
include:
- master
- user/*
- refs/pull/*
When the pipeline testsign
was triggered by a PR (with Build Validation branch policies set for Azure Repos), the value of $(Build.SourceBranch)
was refs/pull/<prId>/merge
, which was an intermediate branch between the PR source and target branches. Apparently in the current YAML definition from master
branch of your pipeline B, that pipeline resource didn't include
such branches in the trigger
property.
Besides, please note that YAML pr
triggers are supported only in GitHub and Bitbucket Cloud but not used for Azure Repos.