Can I ask Jenkins to ignore return code?

3,878 views
Skip to first unread message

Pete Akey

unread,
Apr 16, 2013, 2:30:54 PM4/16/13
to jenkins...@googlegroups.com
Hi,

I'm attempting to connect to a remote machine using sshpass. The script that is being run is exiting with "exit 0" but the exit code that is returned to the Jenkins "Execute shell" is "255". I think CLish is making this task challenging.

Can I ask Jenkins to accept a return code of 255 for this single job?

Here's a quick example for those who are curious. The machine has a CLish shell.

Connect and drop to bash shell in single command:

$ sshpass -p 'password' ssh -t us...@172.16.5.4 'shell'
us...@172.16.5.4:~$ exit 0
exit
Connection to 172.16.5.4 closed.

Back on my machine, check the exit code:

$ echo $?
255

Manually drop to shell on the remote machine with CLish:

$ sshpass -p 'password' ssh us...@172.16.5.4
CLishPrompt> shell
$ exit
exit
CLishPrompt> exit
Connection to 172.16.5.4 closed.

Check the exit code back on my machine:

$ echo $?
0

I don't know why I am getting an exit status of 255 but I need to issue the 'shell' command in a single line and am not sure how else to accomplish what I'm trying to accomplish in the first example without using 'shell'. Therefore, I'd like Jenkins to ignore the fact that the return code is 255 for this one job.

Thanks.

Mandeville, Rob

unread,
Apr 16, 2013, 2:39:40 PM4/16/13
to jenkins...@googlegroups.com
$ sshpass -p 'password' ssh -t us...@172.16.5.4 'shell' || true

If the sshpass command returns nonzero ("fails"), you then run and return the value of the 'true' program.

--Rob
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


The information in this message is for the intended recipient(s) only and may be the proprietary and/or confidential property of Litle & Co., LLC, and thus protected from disclosure. If you are not the intended recipient(s), or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any use, dissemination, distribution or copying of this communication is prohibited. If you have received this communication in error, please notify Litle & Co. immediately by replying to this message and then promptly deleting it and your reply permanently from your computer.

Pete Akey

unread,
Apr 16, 2013, 2:42:36 PM4/16/13
to jenkins...@googlegroups.com
Thanks! Worked like a charm.
Reply all
Reply to author
Forward
0 new messages