Azure Devops - 在拉取请求上触发管道,但不在推送上触发管道?

发布于 2025-01-14 07:59:04 字数 408 浏览 3 评论 0原文

我有一个 ADO git 存储库,其中包含基于 YAML 的构建管道,该管道构建 docker 映像,使用 Docker Compose 运行一些测试,然后将映像和 helm 图表推送到 ACR。

我希望构建/测试部分也能在 PR 上运行。我创建了第二个管道,它只是正常构建的前半部分,并将其分配为分支的构建验证管道。

但是,我似乎无法正确触发。如果我在测试管道中有trigger: none,它永远不会触发。如果我有分支名称,它也会与正常的构建管道一起在合并时运行。这应该如何运作?该文档定义了所有各个部分,但并没有真正定义它们如何交互!

我是否应该有一个多级管道并以某种方式使用它进行验证? (目前只是一个阶段中一项工作的 4 个步骤)。

我希望避免多次构建相同的图像,或在构建代理之外的任何地方存储未经测试的图像。

I have a ADO git repo with a YAML-based build pipeline that builds a docker image, runs some tests using Docker Compose, and then pushes the image and a helm chart to an ACR.

I'd like the have the build/test part run on PRs too. I have created a second pipeline that's just the first half of the normal build, and assigned it as a Build Validation pipeline for a branch.

However, I don't seem to be able to get the triggers right. If I have trigger: none in the test pipeline, it never triggers. If I have branch names, it is also run on merge alongside the normal build pipeline. How is this supposed to work? The docs define all the individual parts, but not really how they are expected to interact!

Am I supposed to have a multistage pipeline and use that somehow for the validation? (it's just 4 Steps in one Job in one Stage currently).

I am hoping to avoid building the same image too many times, or storing untested images anywhere outside the build agent.

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

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

发布评论

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

评论(1

白日梦 2025-01-21 07:59:04

我使用以下配置使其工作:

在我的 YAML 管道中,我设置了trigger: none

在分支的分支策略中,我创建了一个带有自动触发器的构建验证:
输入图片这里的描述

然后我创建一个到该分支的拉取请求,管道会自动运行:
输入图片这里的描述

有两个可能的错误:

  1. 在构建验证中选择了“手动”触发器,因此管道需要手动运行而不是自动触发。
  2. 设置了分支策略的分支应该与拉取请求的目标分支是同一分支。

I make it work with the following configuration:

In my YAML pipeline, I set the trigger: none.

In branch policies of a branch, I create a build validation with automatic trigger:
enter image description here

Then I create a pull request to that branch, and the pipeline runs automatically:
enter image description here

There are two possible mistakes:

  1. The "Manual" trigger is selected in build validation, so that the pipeline needs to be run manually rather than triggered automatically.
  2. The branch with branch policy set should be the same branch as the target branch of pull request.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文