I’ve just been experimenting with Jenkins and setting up a few projects. One inparticular calls a shell script and the exit code from that script is picked up correctly, producing a pass/fail. Yet when I call Scala from the command line, it passes no matter what happens.
In the Execute shell box:
/opt/scala/2.9.1/bin/scala sdfsdfsd
Exception in thread "main" java.lang.RuntimeException:
Cannot figure out how to run target: sdfsdfsd
... (stack trace removed)
Finished: SUCCESS
Yet doing the equivalent with Java produces a failure:
/opt/java/jdk1.7.0/bin/java sdfdfsd
Error: Could not find or load main class sdfdfsd
Finished: FAILURE
Both of these produce an exit code of 1 when running from bash (with echo $?)
Am I missing something or is this a bug?
EDIT:
Interestingly, I am seeing the same behaviour when using ant exec – when I call a shell script containing an invalid call to scala I get the expected error code, but via ant (with failonerror=’true’) I see zero and build successful.
Thanks
This is a known bug Scala eats exit code when piping stdin, fixed in trunk.
To patch your system, the fix is quite easy, in the $SCALA_HOME/bin/scala script, line 25ish
Move the exit to outside the if:
This will fix your problem (in ant as well actually, but you will have to do the same thing for scalac).