azure-devops - 基于触发器的不同代理池或对同一 Azure Pipeline 的需求
问题描述
master
我有一个用 YAML 编写的 Azure Pipeline,只要对分支进行更改,它就会从 CI 触发器运行。它也可以从拉取请求或用户针对任何分支手动触发。
由于使用了许多许可组件,因此构建master
需要在特定代理上运行。其他构建没有,实际上我宁愿它们在其他代理上运行。
所以我的问题是,有没有办法根据触发构建的原因或构建正在构建的分支在 YAML 管道中指定不同的代理/池?我希望这是在管道中永久配置的行为,而不是要求用户更新他们希望在其他地方构建的每个分支上的 YAML。
在有关 pool/demands/condition 关键字的文档部分中,我看不到任何明显的内容。
解决方案
我通过将steps
for 作业放入模板来解决这个问题,然后在管道中创建一组具有不同condition
条目的作业,以便我们可以demands
根据这些条件进行设置。
骨架版本如下所示:
- stage: Build
jobs:
- job: TopicBranchAndPullRequestBuild
condition: or(startsWith(variables['Build.SourceBranch'], 'refs/heads/topic'), startsWith(variables['Build.SourceBranch'], 'refs/pull'))
displayName: 'Build topic Branch or Pull Request'
pool:
name: the-one-and-only-pool
demands:
- HasLicensedComponents -equals false
steps:
- template: build-template.yml
- job: MasterAndReleaseBranchBuild
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release'))
displayName: 'Build master or release Branch'
pool:
name: the-one-and-only-pool
demands:
- HasLicensedComponents -equals true
steps:
- template: build-template.yml
显然,此处给出的值仅作为示例,否则这就是我的工作。
推荐阅读
- spring - Spring-boot应用程序部署问题
- unit-testing - 在 Rust 中比较函数是否相等
- amazon-web-services - 为什么我的 CodeDeploy 到 lambda 不起作用?
- web-scraping - 如果亚马逊不通过 API 提供这些信息,Jungle Scout 和 ASINspector 等服务如何提供亚马逊评论/评级数据?
- jhipster - JHIPSTER OKTA invalid_id_token
- reactjs - 如何测试从状态读取的反应组件
- java - 如何限制 EditText 输入只允许 3 位整数或小数
- java - 当用户在微调器中选择项目时如何在项目回收器视图中设置图像
- typescript - 无法从控制器 ExpressJS + Typescript 返回 next()
- javascript - 如果只有 3 个以上的字母 javascript 如何获得 varaiable