gpt4 book ai didi

github - 如果 gitlab 管道中的条件为真,则运行依赖项作业

转载 作者:行者123 更新时间:2023-12-04 08:19:21 25 4
gpt4 key购买 nike

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

build:
stage: build
when: manual
script:
- echo build
test:
stage: test
when: manual
dependencies:
- build
if [ $deploy = 'true' ]
script:
- echo test

最佳答案

Gitlab 文档是一个很好的起点,尤其是 rules section .

The rules keyword can be used to include or exclude jobs in pipelines.

Rules are evaluated in order until the first match. When matched, thejob is either included or excluded from the pipeline, depending on theconfiguration. If included, the job also has certain attributes addedto it.


这意味着您可以使用这种逻辑参与的规则,在您的情况下,它看起来像
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 文档中的以下指令:
  • rules
  • needs
  • 关于github - 如果 gitlab 管道中的条件为真,则运行依赖项作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65564847/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com