0

Quite new to the CI/CD pipelines in AzDO. I was going through some official Azure Pipeline documents where I have some doubts on Schedule Triggers.

Below is a pipeline Snippet in main branch:

schedules:
- cron: "0 0 * * *"
  displayName: Daily midnight build
  branches:
    include:
    - main
    - releases/*
    exclude:
    - releases/ancient/*
- cron: "0 12 * * 0"
  displayName: Weekly Sunday build
  branches:
    include:
    - releases/*
  always: true

The documentation says the Pipeline will run for branches "main" and "releases" at midnight if there has been some changes to those branches since the last successful scheduled run and build the "releases" branch on sunday irrespective of changes to releases branch which seems understandable.

Which means we can control other branches (e.g. releases) to build from YAML file present in another branch (e.g. main).

Again, the documentation also states, for below YAML in a release branch

# YAML file in the release branch
schedules:
- cron: "0 0 * * *"
  displayName: Daily midnight build
  branches:
    include:
    - main

The pipeline won't build "release" branch since the branch name is missing under "branches" section. But will it build the "main" branch though since it's mentioned under "branches" section?

If no, then how can the first YAML in main branch make "releases" branches to build? Does the YAML file in main/default branch has some special capabilities?

If yes, does it really make sense to build "main" branch from release/non-main branches?

Thanks in advance.

4

1 回答 1

0

如果不是,那么主分支中的第一个 YAML 如何使“发布”分支构建?main/default 分支中的 YAML 文件是否有一些特殊功能?

Azure Pipelines 中有一个默认分支设置(编辑管道 -> 获取源 -> 手动和计划构建的默认分支),它告诉管道要评估哪个分支以进行计划运行。Yaml 构建使用与经典管道相同的调度,并且在该默认分支中对 yaml 文件的更改会反映在调度程序中。

或者换句话说,Azure DevOps 中的管道与存储库中的 yaml 文件是分开的。在 repo 中创建 yaml 文件后,您需要在 Azure DevOps 中创建管道,通过新管道 -> 选择 repo -> 现有 Azure Pipelines yaml 文件(或创建新的 yaml 文件)。此步骤创建实际管道,该管道具有存储在 Azure DevOps 数据库中某处的自己的配置。这些配置指向为管道运行评估的 yaml 文件以及文件何时更改。

如果您手动对管道进行排队,并选择默认分支以外的其他分支,则会评估您选择的分支中的 yaml 文件。此外,在评估分支触发器时,管道会评估分支提交中的 yaml 文件。因此,如果您在主分支中有此触发器:

trigger:
 - main
 - feature/*

这在 feature/foo -branch 中:

trigger:
 - main

对 feature/foo 分支的提交不会触发管道。

(不确定我是清楚地回答了这个问题还是只是增加了一些混乱,但是你去吧。Azure Pipelines 中的触发器实现一开始有点混乱。)

于 2021-10-25T06:42:14.443 回答