简体   繁体   English

GitHub PR 合并不会触发 Azure DevOps Pipeline

[英]GitHub PR Merge does not trigger Azure DevOps Pipeline

I have my repository on GitHub and my CI/CD pipelines on Azure DevOps.我在 GitHub 上有我的存储库,在 Azure DevOps 上有我的 CI/CD 管道。 What I want to achieve is, that once a PR merges onto the master branch that the pipeline deploys.我想要实现的是,一旦 PR 合并到管道部署的主分支上。 No PR creation should trigger the pipeline.没有 PR 创建应该触发管道。 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.但是如果我通过 GitHub PR 来做,什么也不会发生。 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.我对来自 Github 的 Pull-Requests 有类似的看法。 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.只需编辑管道并在“...”下拉选择触发器,然后转到“Pull Request Validation”行并启用它。 Lastly pick the target branch.最后选择目标分支。

Note: sometimes is can take a few minutes for DevOps to pick it up.注意:有时 DevOps 可能需要几分钟的时间来处理它。

I'd suggest just use trigger for CI我建议只为 CI 使用trigger

trigger:
branches:
    include:
        - master

Omit the pr section.省略pr部分。

This would then run your pipeline whenever you make a PR to master as well as once you complete the PR.这将在您制作 PR 以掌握以及完成 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现在为了防止管道在您制作 PR 时运行,并且只有在您完成 PR 以掌握时,请在构建阶段使用条件

- 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.无论如何,我用一个空的存储库尝试了触发器,它就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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