主服务器的Azure DevOps CI管道由分支中的更改触发,反之亦然 [英] Azure DevOps CI pipeline for master being triggered by changes in branch and vice versa

查看:89
本文介绍了主服务器的Azure DevOps CI管道由分支中的更改触发,反之亦然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于仓库的CI构建触发器设置,如下所示:

I have a CI build trigger setup for a repo as follows:

trigger:
- master

我有一个与自己的管道相同的仓库的分支.

I have a branch of the same repo that I would like to have it's own pipeline.

在分支的pipeline.yml中,我有:

In the pipeline.yml for the branch I have:

trigger:
- ops-workshop/ms-lab01

但是,如果我将更改提交到分支,则将同时为主管道和分支管道触发构建.

However, if I commit changes to my branch, builds are triggered for both the master and branch pipelines.

提交给master也会触发分支的管道(不应该这样做).

Committing to master also triggers the pipeline for the branch (which it shouldn't).

我尝试使用 branches 节点排除主节点,但似乎没有任何效果.参见:

I have tried using the branches node to exclude master but it doesn't seem to have any effect. See:

trigger:
  branches:
    include:
    - ops-workshop/ms-lab01
    exclude:
    - master

似乎唯一可以阻止针对主管道触发构建的事情是,如果我使用通配符运算符排除所有内容,则不会触发任何构建.

The only thing that seems to stop builds from being triggered against the master pipeline is if I use the wildcard operator to exclude everything - no builds are then triggered.

如果有不同,我会在Azure DevOps门户中进行这些更改.

I am making these changes in the Azure DevOps portal if that makes a difference.

这似乎很琐碎,但是我不明白为什么即使设置了排除条件,我也要为同一次提交触发两个管道.

This seems to be something very trivial, but I don't understand why I'm getting two pipelines triggered for the same commit, even with exclusions set.

我的完整YAML文件如下所示:

My full YAML file looks like this:

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- ops-workshop/ms-lab01

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

任何建议将不胜感激.

推荐答案

我看到2条您可以检查的建议/事物.

I see 2 suggestions/things you can check.

首先检查在构建管道定义YAML-> GetSources->(图像)中默认设置了哪个分支

First check which branch is set by default in build pipeline definition, YAML -> GetSources -> (image)

第二个方法是尝试在构建管道定义中设置触发的分支,选择选项触发器",覆盖yaml,然后在此处设置分支(查看图像)

Second is to try set triggered branches in build pipeline definition, choose option "Triggers", override yaml, and set branches there (look at image)

这篇关于主服务器的Azure DevOps CI管道由分支中的更改触发,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆