CI/CD 管道开发实用指南
1. 条件变量
条件变量是变量的一种特殊情况,它可以根据特定条件为变量赋值。例如,测试环境的 HTTP 端点与生产环境的 HTTP 端点不同。以下是 Azure DevOps 中条件变量的示例:
variables:
- name: endpoint
${
{ if eq( parameters['target'], 'test') }}:
value: 'https://mycompany.test.com'
${
{ if eq( parameters['target'], 'production') }}:
value: 'https://mycompany.com'
2. 管道中的条件
管道中的条件是不可或缺的。脚本化管道中的条件使用 if/then/else 结构实现,而声明式管道中的条件结构通常不同,会根据平台使用 if 、 when 或 condition 等关键字。以下是不同平台的条件示例:
- GitLab :
job:
script: echo " Run Analyze code in case of the main branch"
rules:
- if: $CI_COMMIT_BRAN
超级会员免费看
订阅专栏 解锁全文
1341

被折叠的 条评论
为什么被折叠?



