简体   繁体   中英

GitHub PR Merge does not trigger Azure DevOps Pipeline

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!

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.

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.....

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM