azure-devops - 在 Azure Devops 中使用多存储库 CI 设置确定触发分支
问题描述
在 ADO 中,您可以根据本文档创建一个“存储库资源” 。“触发器”部分允许您为空间中的任何 Azure 存储库定义 CI 触发器。因此,给定以下配置:
回购:
- AzureRepo1 - 包含应构建的项目文件
- AzureRepo2 - 包含管道文件“pipeline.yml”
resources: repositories: - repository: "Azure_Repo_1" type: git name: AzureRepo1 ref: development trigger: branches: include: - development - staging - production pool: vmImage: 'windows-latest' jobs: - template: Template.yml parameters: service: "development" run_tests: true
当我对 AzureRepo1 进行更改时,管道会触发。在运行时,我将如何确定目标存储库 (AzureRepo1) 的哪个分支(“生产”、“暂存”或“开发”)触发了构建?理想情况下,输入示例模板的“服务”参数将动态反映哪个分支触发了构建。
注意:“Build.SourceBranch”和“Build.SourceBranchName”似乎从托管 YML 文件的存储库(在本例中为 AzureRepo2)中提取了分支。
我错了。这些按预期运行。使用以下解决方案。
解决方案
根据此处的文档:
当对其中一个存储库的更新触发管道时,会根据触发存储库设置以下变量:
- 构建.存储库.ID
- Build.Repository.Name
- Build.Repository.Provider
- Build.Repository.Uri
- 构建.SourceBranch
- Build.SourceBranchName
- 构建.SourceVersion
- Build.SourceVersionMessage
对于触发存储库,触发管道的提交决定了检出代码的版本。对于其他存储库,在 YAML 中为该存储库资源定义的 ref 确定了检出的默认版本。
如果在 AzureRepos1 上发生触发器,您应该在其中具有正确的分支名称Build.SourceBranchName
推荐阅读
- r - 如何使用 Rscript 将控制台输出写入文本文件,就像使用 R CMD BATCH 一样
- database - 在 go http 的自定义处理程序中传递 *gorm.db 实例的最佳实践
- spring-cloud-stream - 幂等接收器 - 是否有任何等效于 StreamListener 的 FilteringMessageListenerAdapter/RecordFilterStrategy
- php - 从缺少字母的单词中查找 txt 列表中的单词
- c++ - 读取内存的特定地址并将其解释为所需的类型
- ffmpeg - Windows 上的 FFmpeg 库 - 未定义的引用
- data-warehouse - 用于数据仓库和空间查询的 NewSQL
- laravel-5 - 如何在 php / laravel 中从谷歌存储中压缩和下载文件夹和子文件夹
- linux - Linux中的计时器是哪个计时器?
- php - CURL POST 登录和重定向似乎不起作用