shell-dependent issues with exit code in jenkins

43 views
Skip to first unread message

Chris

unread,
Feb 21, 2019, 7:22:10 AM2/21/19
to jenkins...@googlegroups.com
Hi,

I'm not sure if this is a jenkins issue or a shell issue, but it looks like things work as they should during direct execution from a shell, but not as it should in "Execute shell" inside jenkins.

I made an extremely simple job in jenkins to demonstrate the problem and it only has this as its shell command:

#!/bin/csh
exit 1

I then run the job and get this on the console:

[workspace] $ /bin/csh /tmp/jenkins4977554484883756741.sh
Finished: SUCCESS

That seems wrong, how can it succeed on exit 1? Running it directly from a shell prints
"Exit 1"
and "echo $?" prints out "1" so I don't see how the shell itself can be at fault here.

Then I do the same thing in jenkins, but change to /bin/sh, i.e. the "Execute shell" is now:

#!/bin/sh
exit 1

This gives a failing job as one would expect:

[workspace] $ /bin/sh /tmp/jenkins4894024285990311119.sh
Build step 'Execute shell' marked build as failure
Finished: FAILURE

I've tried playing around with the -e flag but no difference.

Is this some know issue with jenkins+csh or is csh just completely bad?
I *think* that this used to work earlier, but may have stopped working in some jenkins upgrade. Not sure though, perhaps it has always been broken. Currently running jenkins 2.164.

(and before you ask: using csh is not my choice, but there are some legacy scripts that I'm currently not allowed to port to a more reasonable shell)

TIA,
Chris
Reply all
Reply to author
Forward
0 new messages