gpt4 book ai didi

azure - 打开 github PR 时未触发 pr(Azure 管道 YAML)

转载 作者:行者123 更新时间:2023-12-05 01:09:37 26 4
gpt4 key购买 nike

目标

我对 Azure 和管道还很陌生,我正在尝试从 Azure 中的 pr 触发管道。该存储库位于 Github 中。

这是管道 yaml:pipeline.yml

trigger: none # I turned this off for to stop push triggers (but they work fine)

pr:
branches:
include:
- "*" # This does not trigger the pipeline

stages:
- stage: EchoTriggerStage
displayName: Echoing trigger reason
jobs:
- job: A
steps:
- script: echo 'Build reason::::' $(Build.Reason)
displayName: The build reason

# ... some more stages here triggered by PullRequests....
# ... some more stages here triggered by push (CI)....

Github 上的 pr 如下所示: enter image description here

问题

但是,当推送触发器正常工作时,管道不会被触发。

我已阅读docs但我不明白为什么这不起作用。

当我通过 git push 触发管道时,管道工作得非常正常。然而,当我尝试用 Github 上的 PR 触发它时,什么也没有发生。在上面的代码中,我尝试关闭推送触发器,并允许所有 pr 触发管道。还是什么都没有。

我还不想删除管道并创建新管道。

更新

我更新了 yaml 文件以按照下面的建议工作。由于管道现在实际上通过推送命令运行,因此 yaml 文件的其余详细信息不相关并被省略。

我尝试过的其他事情

  • 在 Github 上创建新 PR
  • 关闭/重新开放 Github 上的 PR
  • 对 Github 上的现有 PR 进行更改

-> 仍然没有触发管道。

最佳答案

您的管道中有错误。应该是这样的:

trigger: none # turned off for push

pr:
- feature/automated-testing

steps:
- script: echo "PIPELINE IS TRIGGERED FROM PR"

请更改此设置

  - stage:
- script: echo "PIPELINE IS TRIGGERED FROM PR"

  - stage:
jobs:
- job:
steps:
- script: echo "PIPELINE IS TRIGGERED FROM PR"

编辑

我使用了你的管道


trigger: none # I turned this off for to stop push triggers (but they work fine)

pr:
branches:
include:
- "*" # This does not trigger the pipeline

stages:
- stage: EchoTriggerStage
displayName: Echoing trigger reason
jobs:
- job: A
steps:
- script: echo 'Build reason::::' $(Build.Reason)
displayName: The build reason

# ... some more stages here triggered by PullRequests....
# ... some more stages here triggered by push (CI)....

一切似乎都正常。

这里是PR在这里 build for it

enter image description here

我没有这样做,但您可以尝试通过分支策略强制执行此操作。要执行此操作,请转到存储库设置,然后如下所示:

enter image description here

关于azure - 打开 github PR 时未触发 pr(Azure 管道 YAML),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65035156/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com