只有在YAML提出拉动请求时,我才能运行一个舞台

发布于 2025-02-11 18:51:06 字数 48 浏览 4 评论 0原文

我正在学习yaml,并希望在特定分支上提出拉请请求时才能运行一个阶段。我该怎么做?

Im learning YAML and want a stage to run only when a PULL Request has been made on a particular branch. How can i do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云裳 2025-02-18 18:51:06

要仅在特定分支上提出拉请请求时运行阶段,您可以在舞台上设置条件。

condition: and(eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/branchname'), eq(variables['Build.Reason'], 'PullRequest'))

以下是一个示例:

stages:
- stage: A
  condition: and(eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/branchname'), eq(variables['Build.Reason'], 'PullRequest'))
  jobs:
  - job: A1
    steps:
      - script: xx

您可以使用预定义的变量:system.pullrequest.targetBranchbuild.Reason来过滤触发方法并拉请求目标分支。

有关更多详细信息,您可以参考文档:条件预定义变量

To run a stage only when a pull request has been made on a particular branch, you can set the condition in the stage.

condition: and(eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/branchname'), eq(variables['Build.Reason'], 'PullRequest'))

Here is an example:

stages:
- stage: A
  condition: and(eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/branchname'), eq(variables['Build.Reason'], 'PullRequest'))
  jobs:
  - job: A1
    steps:
      - script: xx

You can use predefined variables: System.PullRequest.TargetBranch and Build.Reason to filter the trigger method and pull request target branch.

For more detailed info, you can refer to the docs: Condition and Predefined variables.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文