3

We have a Scala project and we use SBT as its build tool. our CI tool is TeamCity, and we build the project using the command line custom script option with the following command:

call %system.SBT_HOME%\bin\sbt clean package

The build process works fine when the build succeeds, however, when compilation fails - TeamCity thinks that the script exited with exitCode 0 and not 1 as expected, this cause TeamCity build to succeed although the compilation failed.

when we run the same commands on local cmd we see that the errorLevel is 1.

the relevant part of the build log:

[11:33:44][Step 1/3] [error] trait ConfigurationDomain JsonSupport extends CommonFormats {
[11:33:44][Step 1/3] [error]                           ^
[11:33:44][Step 1/3] [error] one error found
[11:33:45][Step 1/3] [error] (compile:compile) Compilation failed
[11:33:45][Step 1/3] [error] Total time: 12 s, completed Jan 9, 2014 11:33:45 AM
[11:33:45][Step 1/3] Process exited with code 0

how can we make TeamCity recognize the failure of the build?

Yosefki
  • 383
  • 7
  • 22

2 Answers2

0

Try explicitly exit with:

call %system.SBT_HOME%\bin\sbt clean package
echo the exit code is %errorlevel%
exit /b
Jifeng Zhang
  • 5,037
  • 4
  • 30
  • 43
0

If you can't get the process to output a non-zero exit code then you could use a build failure condition based on specific text in the build log. See this page for the documentation but in essence you can get the build to fail if it finds the text error found in the build log.

Paul Hunt
  • 3,395
  • 2
  • 24
  • 39
  • Yes, i have done it. but this option only for the whole build and not build step, still it is a solid solution. – Yosefki Jan 12 '14 at 12:41