Gitlab 是否允许CI/CD作业中的脚本失败?
整个作业 在一系列脚本中,是否有一个脚本允许失败(其他脚本允许失败)?Gitlab 是否允许CI/CD作业中的脚本失败?,gitlab,gitlab-ci,Gitlab,Gitlab Ci,整个作业 在一系列脚本中,是否有一个脚本允许失败(其他脚本允许失败)? job1: stage: test script: - execute_script_that_MAY_fail_and_should_be_marked_somehow_in_this_config_as_such - execute_script_that_MUST_NOT_fail 其基本原理是,可能存在相关的脚本,它们应该分组在一起并按顺序进行,并且只允许其中一些脚本失败 例如,docker
job1:
stage: test
script:
- execute_script_that_MAY_fail_and_should_be_marked_somehow_in_this_config_as_such
- execute_script_that_MUST_NOT_fail
其基本原理是,可能存在相关的脚本,它们应该分组在一起并按顺序进行,并且只允许其中一些脚本失败
例如,docker部署具有构建
(不得失败)、容器的停止
(如果容器未运行可能会失败)和运行
(不得失败)
我目前的解决办法是将其分为不同的工作,但这是一个丑陋的黑客行为:
stages:
- one
- two
- three
one:
stage: one
script:
- execute_script_that_MUST_NOT_fail
two:
stage: two
script:
- execute_script_that_MAY_fail
allow_failure: true
three:
stage: three
script:
- execute_script_that_MUST_NOT_fail
如果作业中的任何脚本步骤返回失败状态,则作业将失败。因此,您需要防止这种情况发生,最简单的方法是在步骤中添加
| | true
(或@ahogen在注释中建议的一些日志记录):
如果作业中的任何脚本步骤返回失败状态,则作业将失败。因此,您需要防止这种情况发生,最简单的方法是在步骤中添加
| | true
(或@ahogen在注释中建议的一些日志记录):
对此,请使用BASH语法。对于允许失败的单个命令/脚本,我们可以打印它失败,但可以使用bash或(双管道)继续<代码>我的脚本| |回显“我的脚本失败($?)”我有一个类似的问题。我想忽略
日志记录
步骤中的任何错误:改用BASH语法。对于允许失败的单个命令/脚本,我们可以打印它失败,但可以使用bash或(双管道)继续<代码>我的脚本| |回显“我的脚本失败($?)”我有一个类似的问题。我想忽略日志记录
步骤中的任何错误:
stages:
- one
- two
- three
one:
stage: one
script:
- execute_script_that_MUST_NOT_fail
two:
stage: two
script:
- execute_script_that_MAY_fail
allow_failure: true
three:
stage: three
script:
- execute_script_that_MUST_NOT_fail
job1:
stage: test
script:
- execute_script_that_MAY_fail || true
- execute_script_that_MUST_NOT_fail