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

查看:57
本文介绍了如何停止针对每个分支运行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.

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

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),并且我对分支"development"设置了分支策略,以在每次更改时触发验证构建里面有Main.sln的Main文件夹(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)'

推荐答案

设置;

# 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构建管道,当成功的PR影响到 ProjectA 时将触发该管道.

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

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

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