Azure-devops-docs: Understanding manual PR comment triggers

Created on 12 May 2019  Â·  8Comments  Â·  Source: MicrosoftDocs/azure-devops-docs

I have a long validation build that I want to run only on new commits to master and when explicitly requested in a PR via a comment /azp run Validation.

The YAML for the Validation pipeline contains:

trigger:
- master
pr: none

When I post the "/azp .." comment in the PR then the bot responds with:
> Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

How should this work?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 devops-cictech devopprod doc-bug

Most helpful comment

I had the exact same problem but finally figured it out.

Setting pr: none in the YAML will disable this pipeline for any PR, even with comment triggers.
That's why AZP is reporting it can't run the pipeline.
So you should either not specify pr or set it to a branch you want to restrict it to. (like pr: master for only PRs targeting master)

Now the problem is that PRs will automatically trigger your pipeline.
To allow only comments to trigger it, you need to follow these instructions:
https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#build-github-pull-requests-only-when-authorized-by-your-team
Note that there is no way of letting one of your contributors (without access to Azure DevOps) to trigger a build with a comment.

The way the docs is structured is a bit misleading here.
Those instructions are mandatory to enable comment triggers, but is put in a subpart which can be understand as optional and there is no mention of pr: none disabling comment triggers.

It took me a while to understand how it was actually supposed to work.

All 8 comments

I had the exact same problem but finally figured it out.

Setting pr: none in the YAML will disable this pipeline for any PR, even with comment triggers.
That's why AZP is reporting it can't run the pipeline.
So you should either not specify pr or set it to a branch you want to restrict it to. (like pr: master for only PRs targeting master)

Now the problem is that PRs will automatically trigger your pipeline.
To allow only comments to trigger it, you need to follow these instructions:
https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#build-github-pull-requests-only-when-authorized-by-your-team
Note that there is no way of letting one of your contributors (without access to Azure DevOps) to trigger a build with a comment.

The way the docs is structured is a bit misleading here.
Those instructions are mandatory to enable comment triggers, but is put in a subpart which can be understand as optional and there is no mention of pr: none disabling comment triggers.

It took me a while to understand how it was actually supposed to work.

@TimLariviere Thanks for your follow up- tagging as a doc-bug for triage on our side.

@thomps23 2 follow-up questions:

  1. Should it be possible to have 2 Pipelines, where Pipeline1 is triggered automatically (for PRs), while Pipeline2 is (only) triggered via /azp run Pipeline2?

  2. Within an executing Pipeline, do any Variables indicate the Build was Triggered from a PR Comment?
    I've noticed Build.Reason is still PullRequest for builds triggered with PR Comments & Build.TriggeredBy.* Variables are unrelated.

@JoeBrockhaus Thanks. We'll consider those questions during triage but I can't put a fine point on when. If this is urgent please consider creating a discussion at Azure DevOps on Stack Overflow.

@JoeBrockhaus We're doing 1., eg. having two pipelines, where one is always triggered (fast, just compiles and runs tests), and the other one only on comment triggers (slower, builds and deploys for QA).

Both are set up with

trigger: none
pr: 
  - master

but the slow one has Require a team member's comment before building a pull request turned on (pipeline -> Settings -> Triggers -> PR validation), and we trigger this with /azp run slow-pipeline

I get similar problem, by run /AzurePipelines run, I get "
Azure Pipelines could not run because the pipeline triggers exclude this branch/path."
Then I tried /azp run slow-pipeline, then it gives "No pipelines are associated with this pull request". But after that, a pipeline actually get run, and I do include the branch. But I keep get the same message when run /azurePipelines run, while a pipeline is actually triggered.

I also have the same issue that @GuuBu refers..

I get a message of No Pipelines are associated but then it starts

Thanks for the comments in this thread. We updated the doc to clarify the steps needed to enable comment triggers. There are no explicit variables indicating that the PR has been triggered by a comment.

Was this page helpful?
0 / 5 - 0 ratings