如何在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: