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

查看:88
本文介绍了如何在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:\BVTBin\Tests\installpackage\csilogfile.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

阶段执行结果应该失败,并且不执行下一步:

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

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

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

您需要在gitlab-ci.yml

- # ....
- exit 0

阶段执行结果应为:

然后,当您查看自己的阶段(在我的情况下是第3个阶段)时,结果会确定,可以进入下一个阶段:

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天全站免登陆