如何在 Gitlab CI shell 运行器上构建失败 [英] How to fail a build on Gitlab CI shell runner

查看:50
本文介绍了如何在 Gitlab CI shell 运行器上构建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Windows 10 上运行的 Gitlab CI 运行器:

I have a Gitlab CI runner running on windows 10:

before_script:
  - "echo off"
  - 'call "%VS120COMNTOOLS%vsvars32.bat"'
  - echo.
  - set
  - echo.

stages:
  - build

build:
  stage: build
  script:
  - 'StatusTest.exe'
  #- msbuild...

我正在尝试使用 StatusText.exe 使构建失败(我尝试返回状态代码 -1,0,1;引发异常等)但 Runner 仅记录异常并继续执行以下步骤.

I am trying to fail the build with StatusText.exe (I tried returning status codes -1,0,1; throwing an exception, etc.) But Runner only logs the exception and continues with following steps.

是什么决定了 CI shell 运行器应该使构建失败而不继续下一步?

What determines that CI shell runner should fail the build and not proceed to next step?

输出:

...
windows_tracing_logfile=C:BVTBinTestsinstallpackagecsilogfile.log
$ echo.

$ StatusTest.exe

Unhandled Exception: System.Exception: tralala
   at StatusTest.Program.Main(String[] args)
$ echo "Restoring NuGet Packages..."
...

推荐答案

什么决定了 CI shell 运行器应该使构建失败而不是继续下一步?

What determines that CI shell runner should fail the build and not proceed to next step?

1) 什么时候应该失败

您需要在 gitlab-ci.yml

- # ....
- exit 1

stage执行结果应该失败,不进入下一步:

The stage execution result should fail and does not go to the next step:

然后当您查看您的舞台(在我的情况下为第三个)时,结果将失败:

and then when you look at your stage (in my case the 3rd one) the result will be failed:

您需要在 gitlab-ci.yml

- # ....
- exit 0

阶段执行结果应该是:

然后当您查看您的阶段(在我的情况下为第三阶段)时,结果将是好的并准备好进入下一个阶段:

and then when you look at your stage (in my case the 3rd one) the result will be Ok and ready to go to the next stage:

这篇关于如何在 Gitlab CI shell 运行器上构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆