如何停止为每个分支运行 azure dev ops yaml 验证构建? [英] How to stop azure dev ops yaml validation build from running for each branch?

查看:14
本文介绍了如何停止为每个分支运行 azure dev ops yaml 验证构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为 CICD 使用 azure dev ops 并验证 PR.

We are using azure dev ops for CICD and validating PR's.

昨天我决定开始为验证构建制作 yaml 文件.

Yesterday I decided to start making yaml files for validation builds.

我创建了管道.我为开发"设置了分支策略,验证构建运行正常.

I created the pipeline. I set the branch policy for 'development' fine and the validation build ran okay.

但是,我看到的是,每次任何分支更改目录的文件时,我都会为构建触发器设置验证构建.

However, something I see is that each time ANY branch gets a change to the files of the directory I've set the validation build for a build triggers.

所以,假设我为项目 Main(src/Main) 创建了一个 yaml 管道(仅限 CI),并且我已经在分支开发"上设置了一个分支策略,以便在发生更改时触发验证构建里面有 Main.sln 的主文件夹(src/Main/*),它是来自分支的 PR(即 feature/Main/FirstPR).这可行,但是如果我将开发"合并到任何尚未更改主目录的分支中,它将触发该构建.除了开发之外,没有其他分支策略包括对 Main 的验证,即使它还没有被 PR-ed,只是简单地推送到.

So, let's say I've made a yaml pipeline(CI only) for project Main(src/Main) and i've set a branch policy on branch 'development' to trigger a validation build whenever there is a change to that Main folder(src/Main/*) with the Main.sln inside and it has been PR's from branch(i.e. feature/Main/FirstPR). This works, but then if i merge 'development' into any branch which has not had the change to the main directory it will trigger that build. No other branch policy includes validation for Main apart from development even if it has not been PR-ed, but simply pushed to.

以下是 yaml 文件的示例.对于任何反馈,我们都表示感谢.

Here is an example of the yaml file. Any feedback would be appreciated.

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

pool:
  vmImage: 'windows-2019'
  demands: 
      - msbuild
      - visualstudio
      - vstest

variables:
  solution: 'src/Main/Main.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1
  inputs: 
    versionSpec: '5.0.0'

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'select'
    vstsFeed: '5aaa76ac-3bqa-4567-usd9-btdse1c4c66a'
    restoreDirectory: '../../packages'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

推荐答案

Set;

# A pipeline with no trigger
trigger: none

在您的验证构建管道上.无论推送了哪些分支/路径,这都会停止构建运行.

On your validation build pipeline. This will stop the build being run regardless of which branch / paths have been pushed.

验证构建管道仍将遵守您为 PR 设置的分支策略.

The validation build pipeline will still respect the branch policies you've setup for PRs.

然后你可以有类似的东西;

You can then have something like;

  paths:
    include:
      - 'src/ProjectA/*'
  branches:
    include:
      - development  

对于您的 CI 构建管道,当有影响 ProjectA 的成功 PR 时将触发.

For your CI build pipelines which will trigger when there's a successful PR that affects ProjectA.

这篇关于如何停止为每个分支运行 azure dev ops yaml 验证构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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