Jenkins wrong exit value

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
M
Reply | Threaded
Open this post in threaded view
|

Jenkins wrong exit value

M
I'm using two slaves, Windows and Linux. In the first case I have cywing so I execute commands in both slaves through sh:

...
node
(label) {
sh
'''#!/bin/bash -xei
   whoami
   echo $?
   case $- in
       *i*) echo This shell is interactive ;;
       *)   echo This shell is not interactive ;;
   esac
   echo d = $?'''

}
...


I put the $? in order to understand why, sometimes, after executing the build Jenkins returns an error (script returned exit code -1) even if all the exit values are 0s. It seems to be a random error. Most of the time the build is correct, but in some cases it returns this annoyng -1 exit value without a reason.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/92a3b42b-e78d-4420-9596-82dde92f9fec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Jenkins wrong exit value

Dirk Heinrichs-3
Am 13.11.2017 um 13:40 schrieb M:
I'm using two slaves, Windows and Linux. In the first case I have cywing so I execute commands in both slaves through sh:

...
node
(label) {
sh
'''#!/bin/bash -xei
   whoami
   echo $?
   case $- in
       *i*) echo This shell is interactive ;;
       *)   echo This shell is not interactive ;;
   esac
   echo d = $?'''

}
...


I put the $? in order to understand why, sometimes, after executing the build Jenkins returns an error (script returned exit code -1) even if all the exit values are 0s. It seems to be a random error. Most of the time the build is correct, but in some cases it returns this annoyng -1 exit value without a reason.

Which slave does it fail on, Linux or Windows? -1 sounds really strange because most commands on Linux return positive numbers. Do you have the console log of above script from a failing job? Since you're using "-x" we ought to see which command is failing (and since you're also using "-e", it should be the last one the script has executed).

Wonder why you're using "-i", though...

Bye...

    Dirk
--
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenTextTM Discovery | Recommind
Email: [hidden email]
Website: www.recommind.de

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon Davies, Roger Illing, Registergericht Amtsgericht Bonn, Registernummer HRB 10646

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b9ce5e0d-81e3-3c30-e8ff-bd987f8448ed%40opentext.com.
For more options, visit https://groups.google.com/d/optout.
M
Reply | Threaded
Open this post in threaded view
|

Re: Jenkins wrong exit value

M
Thank you for your reply. The random error appears only in the Windows slave which uses Cygwin. In the console log I only see this when it works correctly:

test #20 completed: SUCCESS

and when it fails:

test #25 completed: FAILURE

The -i is my mistake :)

Il giorno lunedì 13 novembre 2017 14:32:45 UTC+1, Dirk Heinrichs ha scritto:
Am 13.11.2017 um 13:40 schrieb M:
I'm using two slaves, Windows and Linux. In the first case I have cywing so I execute commands in both slaves through sh:

...
node
(label) {
sh
'''#!/bin/bash -xei
   whoami
   echo $?
   case $- in
       *i*) echo This shell is interactive ;;
       *)   echo This shell is not interactive ;;
   esac
   echo d = $?'''

}
...


I put the $? in order to understand why, sometimes, after executing the build Jenkins returns an error (script returned exit code -1) even if all the exit values are 0s. It seems to be a random error. Most of the time the build is correct, but in some cases it returns this annoyng -1 exit value without a reason.

Which slave does it fail on, Linux or Windows? -1 sounds really strange because most commands on Linux return positive numbers. Do you have the console log of above script from a failing job? Since you're using "-x" we ought to see which command is failing (and since you're also using "-e", it should be the last one the script has executed).

Wonder why you're using "-i", though...

Bye...

    Dirk
--
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenTextTM Discovery | Recommind
Email: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="0WbCZFFfBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dirk.he...@...
Website: <a href="http://www.recommind.de" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.recommind.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGAI0xqX2_aTOJli63C7-WL52SKuQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.recommind.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGAI0xqX2_aTOJli63C7-WL52SKuQ&#39;;return true;">www.recommind.de

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon Davies, Roger Illing, Registergericht Amtsgericht Bonn, Registernummer HRB 10646

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a18b716f-22f5-4369-8fe8-2c3d9eb79db9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.