vip*_*pes 6 build-triggers azure-devops azure-pipelines
要求
因此,Azure DevOps 中有一些新功能允许管道触发其他管道,并在此处记录:https : //docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure- devops&tabs=yaml#pipeline-triggers-1听起来不错,除了我无法获得所需的行为。我想在同一个存储库中有 2 个管道:
管道 A 语法
resources:
pipelines:
- pipeline: database
source: database
trigger:
branches:
- develop
- release/*
# The stages filter should work, according to: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml
# However, this error occurs when specifying: /azure-pipelines.yml (Line: 8, Col: 15): Stage filters in pipeline resource database is not supported.
#stages:
#- Build
- pipeline: auth
source: auth
trigger:
branches:
- develop
- release/*
- pipeline: api
source: api
trigger:
branches:
- develop
- release/*
- pipeline: web
source: web
trigger:
branches:
- develop
- release/*
... multiple triggers - 9 in total
stages:
...
Run Code Online (Sandbox Code Playgroud)
当前行为
管道 A 不会被任何其他管道触发,而只会在对其自己的 repo 进行更改时触发。由于它无论如何都会更改自己的存储库,因此它会在无限循环中触发自身。
问题/评论
发现
trigger: none到管道 A 的顶部会阻止它在对其 repo 进行提交时运行,它目前根本不运行!az pipelines run --branch master --name "<PipelineName>" --org "https://dev.azure.com/<OrganisationName>" -p "<ProjectName>"vip*_*pes 10
工作解决方案
因为我的所有构建都集中在一个管道模板中,所以我更改了这个模板以在成功发布工件时触发我的管道 A。这是管道触发代码,它几乎逐字来自(https://docs.microsoft.com/en-us/azure/devops/cli/azure-devops-cli-in-yaml?view=azure-devops),除了从最后几个步骤:
# Updating the python version available on the linux agent
- task: UsePythonVersion@0
displayName: Upgrade build agent Python version
inputs:
versionSpec: '3.x'
architecture: 'x64'
# Updating pip to latest
- script: python -m pip install --upgrade pip
displayName: 'Upgrade pip'
# Updating to latest Azure CLI version.
- script: pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge
displayName: 'Upgrade azure cli'
- script: az --version
displayName: 'Show Azure CLI version'
- script: az extension add -n azure-devops
displayName: 'Install Azure DevOps Extension'
- script: echo ${AZURE_DEVOPS_CLI_PAT} | az devops login
env:
AZURE_DEVOPS_CLI_PAT: $(System.AccessToken)
displayName: 'Login Azure DevOps Extension'
- script: az devops configure --defaults organization=$(System.TeamFoundationCollectionUri) project="$(System.TeamProject)" --use-git-aliases true
displayName: 'Set default Azure DevOps organization and project'
- script: |
set -euo pipefail
if [[ "$(Build.SourceBranch)" == *"/release/"* ]]; then
branchName="master"
else
branchName="develop"
fi
commandLine="--branch $branchName --name <YourPipelineName>"
echo "Triggering release creation with: az pipelines run $commandLine"
az pipelines run $commandLine
displayName: Trigger release build for internal (develop) and external (release) builds
Run Code Online (Sandbox Code Playgroud)
注意事项
<YourPipelineName>适当更改,您的分支名称处理将与我的不同| 归档时间: |
|
| 查看次数: |
5814 次 |
| 最近记录: |