admin管理员组

文章数量:1395730

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!

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!

Share Improve this question asked Mar 27 at 1:38 shravyashravya 334 bronze badges 1
  • Hi @shravya, Good day to you. Have you got a chance to review the answer below and may I know if your pipeline gets triggered upon upstream pipeline completion after including refs/pull/* branches? Hope it may help resolve the issue in this post. Thx for the update and wish you a lovely weekend. – Alvin Zhao - MSFT Commented Mar 28 at 2:14
Add a comment  | 

1 Answer 1

Reset to default 1

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.

本文标签: azure devopsPipeline Resource trigger for every PRStack Overflow