【问题标题】:Instruct gitlab ci to run only certain stages for a commit指示 gitlab ci 只为提交运行某些阶段
【发布时间】:2022-01-03 12:45:46
【问题描述】:

就像 git push -o ci.skip can be used to skip all stages 一样,是否也可以轻松指定要在推送时运行的阶段白名单?

目前我必须在推送后手动转到 gitlab UI 并跳过我不想运行的阶段。在执行此操作时,我还必须手动跟踪阶段依赖关系。

这可以更容易地完成吗?

【问题讨论】:

    标签: gitlab gitlab-ci


    【解决方案1】:

    您可以使用 git push 选项设置 CICD 变量。因此,您可以使用这些变量来设置作业是否运行,使用only:variables/except:variablesrules:

    例如:

    my_job:
      rules:
        - if: $MY_VARIABLE_NEVER
          when: never
        - if: $MY_VARIABLE_ALWAYS
          when: always
        - when: on_success
      # ...
    

    然后你可以使用 push 选项在你的规则中设置变量:

    # excludes my_job from the pipeline
    git push -o ci.variable="MY_VARIABLE_NEVER=true"
    

    这不能直接应用于整个阶段,但您可以为要控制的阶段中的每个作业应用适用的only:/except:rules:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-13
      • 2019-09-21
      • 2017-05-05
      • 1970-01-01
      • 2019-11-15
      • 2021-11-30
      • 1970-01-01
      • 2022-07-04
      相关资源
      最近更新 更多