Reputation: 39
I have my repository on GitHub and my CI/CD pipelines on Azure DevOps. What I want to achieve is, that once a PR merges onto the master branch that the pipeline deploys. No PR creation should trigger the pipeline. Unfortunately I can't seem to get the trigger right. My trigger looks like this:
trigger:
branches:
include:
- master
pr: none
When I push changes onto the master branch, the pipeline gets triggered. But if I do it via GitHub PR, nothing happens. I also tried it with release pipelines but I seem to have the same problem there. Any pointers in the right direction would be much appreciated!
Upvotes: 2
Views: 2346
Reputation: 39
I have figured it out. Something is completely off in my repository. No idea how I managed that, since I thought that should not even be possible. Anyway, I tried the triggers with an empty repository and it works like a charm.
Upvotes: 0
Reputation: 1394
I'd suggest just use trigger
for CI
trigger:
branches:
include:
- master
Omit the pr
section.
This would then run your pipeline whenever you make a PR to master as well as once you complete the PR.
And now to prevent the pipeline from running whenever you make the PR and only once you complete the PR to master, use a condition on your build stage
- stage: 'Build'
displayName: 'Build my application'
condition: eq(variables['Build.SourceBranchName'], 'master')
jobs:
etc.....
Upvotes: 1
Reputation: 479
I had a similar thing with Pull-Requests from Github. In the end i just used the old school "triggers" section and it started working.
Just edit the pipeline and in the "..." drop down selected triggers and then go to the "Pull Request Validation" row and enable it. Lastly pick the target branch.
Note: sometimes is can take a few minutes for DevOps to pick it up.
Upvotes: 0