如何在Gitlab中使作业完成并显示警告

Zhe*_*980 5 exit-code gitlab

我的意思是要获得此状态:

在此处输入图片说明

我可以通过“退出1”失败来完成我的工作,但在警告时不能做同样的事情

Jus*_*wis 24

从13.8开始这是可能的:

test_job:
  script:
    - execute_script_that_will_fail 
  # if the script exit code is 137 or 255 the job will allow to be 
  # failed and the pipeline will continue to run
  allow_failure:
    exit_codes: # User defined exit code
      - 137
      - 255
Run Code Online (Sandbox Code Playgroud)


Mur*_*nik 10

Gitlab 中的警告不是您可以从作业中控制的退出状态,而是作业本身的配置选项。在.gitlab-ci.yml文件中,您需要添加标志allow_failure

somejob:
  stage: test
  script:
    - some_script
  allow_failure: true
Run Code Online (Sandbox Code Playgroud)

如果此作业随后失败(即以不是 的退出代码终止0),它将以警告状态结束,并且不会阻止管道继续。

  • 您可以对此进行投票,以便它成为可能:https://gitlab.com/gitlab-org/gitlab/-/issues/16733 (4认同)