Github 如果gitlab管道中的条件为true,则运行依赖项作业
如果条件为真,我想运行依赖项作业。我们在git实验室中是否有这种可行性。当我使用DEPLOY变量手动触发测试作业时,依赖项应该运行,否则跳过依赖项。我不想在构建阶段保持状态Github 如果gitlab管道中的条件为true,则运行依赖项作业,github,gitlab,devops,gitlab-ci,Github,Gitlab,Devops,Gitlab Ci,如果条件为真,我想运行依赖项作业。我们在git实验室中是否有这种可行性。当我使用DEPLOY变量手动触发测试作业时,依赖项应该运行,否则跳过依赖项。我不想在构建阶段保持状态 build: stage: build when: manual script: - echo build test: stage: test when: manual dependencies: - build if [ $deploy = 'true' ] script:
build:
stage: build
when: manual
script:
- echo build
test:
stage: test
when: manual
dependencies:
- build
if [ $deploy = 'true' ]
script:
- echo test
Gitlab文档是一个很好的起点,尤其是 rules关键字可用于包括或排除管道中的作业 规则按顺序求值,直到第一次匹配为止。如果匹配,则 作业包含在管道中或从管道中排除,具体取决于 配置如果包含,作业还添加了某些属性 去吧 这意味着您可以使用规则进行这种逻辑参与,在您的情况下
build:
stage: build
when: manual
script:
- echo build
test:
stage: test
needs: ['build'] # dependency on previous build stage
script:
- echo test
rules:
- if: '$deploy == "true"' # when true, than run automatically
- if: '$deploy != "true"' # when not true, than run only manually
when: manual
我不确定第二条规则是否需要。但我强烈建议您查看GitLab文档中的以下指令: