Pipeline jobs: How are return codes handled?

6,603 views
Skip to first unread message

David Aldrich

unread,
Apr 21, 2017, 5:52:49 AM4/21/17
to jenkins...@googlegroups.com

Hi

 

In a conventional Jenkins job, my understanding is that the job will fail if the last command of a shell build step indicates an error.

 

I am now experimenting with pipeline jobs and have something like:

 

node {

    stage('Checkout') {<snip>}

 

    sh returnStatus: true, script: '''cd software

                                      make cleanall

                                      make '''

}

 

I am not sure what is happening here.

 

1)      Will the same rule apply that the job will fail if the last command of the sh step fails?

2)      What is ‘returnStatus: true, script’ doing?

 

Best regards

 

David

 

Ramanathan Muthaiah

unread,
Apr 21, 2017, 6:04:38 AM4/21/17
to Jenkins Users, David....@emea.nec.com

David Aldrich

unread,
Apr 21, 2017, 6:14:48 AM4/21/17
to Ramanathan Muthaiah, Jenkins Users

Thanks for your reply but I am still confused.  Looking at:

 

https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#code-sh-code-shell-script

 

returnStatus (optional)

Normally, a script which exits with a nonzero status code will cause the step to fail with an exception. If this option is checked, the return value of the step will instead be the status code. You may then compare it to zero, for example.

 

So if I specify that option I get the status code, but will Jenkins fail the pipeline if the code is non-zero or do I have to do that myself?

 

If I don’t specify that option I will get an exception on a failure.  Will that fail the job neatly or will I get an exception trace?

 

Click here to report this email as spam.

Reply all
Reply to author
Forward
0 new messages