首页 > 解决方案 > 从构建中排除分支(Azure Pipelines)

问题描述

我想从 Azure Pipelines 构建中排除分支。我不想在 Azure Web 平台的配置中指定这一点。相反,我想在azure-pipeline.yml. 所以我做的是这样的:

trigger:
  branches:
    include:
    - '*'
    exclude:
    - artifacts

strategy:
  matrix:
    ubuntu_16_04_gcc_8:
      imageName: 'ubuntu-16.04'
      CC: gcc-8
      CXX: g++-8
      the_name: 'Azure Pipelines'

    windows_2019:
      imageName: 'windows-2019'
      the_name: 'Azure Pipelines'

pool:
  vmImage: $(imageName)
  name: $(the_name)


steps:
 - script: git submodule update --init --recursive
   displayName: "Init Git Submodules"
   condition: succeeded()
 - script: cmake -S . -B ./build/
   displayName: "CMake: Create Project"
   condition: succeeded()
# and some more steps here

预期的行为是没有为 branch 启动构建artifacts。但实际上仍然会触发构建。我需要如何更改yml以实现预期的行为?

标签: azure-pipelines

解决方案


预期的行为是没有为分支工件启动构建。但实际上仍然会触发构建。我需要如何更改 yml 以实现预期的行为?

我测试了您的 YAML 文件,但没有重现您的问题。

要解决此问题,请检查以下建议:

  • 检查artifacts分支下的 YAML 文件。如果我这样设置触发器artifacts

     trigger:
       branches:
         include:
         - '*'
    

    无论您如何在azure-pipeline.yml.

  • 检查触发器选项卡上的触发器设置,以检查您是否选中了复选框Override the YAML continuous integration trigger from here

    在此处输入图像描述


推荐阅读