Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Github 如果gitlab管道中的条件为true,则运行依赖项作业_Github_Gitlab_Devops_Gitlab Ci - Fatal编程技术网

Github 如果gitlab管道中的条件为true,则运行依赖项作业

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:

如果条件为真,我想运行依赖项作业。我们在git实验室中是否有这种可行性。当我使用DEPLOY变量手动触发测试作业时,依赖项应该运行,否则跳过依赖项。我不想在构建阶段保持状态

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文档中的以下指令: