Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-23786

Permit "Execute shell" jobs to return 2 for "unstable"

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Currently, users of "Execute shell" builds must fetch the jenkins-cli jar and execute it in order to mark a build as unstable. For example:

      set -e
      wget ${JENKINS_URL}jnlpJars/jenkins-cli.jar
      make
      if ! make check; then 
        java -jar jenkins-cli.jar set-build-result unstable && exit 0
        exit 1
      fi
      

      will flag as unstable and exit.

      That works, but it's a right pain. The alternative is text-finder plugin string matching, which is arguably worse.

      What'd be ideal is to let the return code 2 mean "unstable" to Jenkins. So one could just replace the above with:

      set -e
      make
      make check || exit 2
      

      I'll see what's involved in adding this, but wanted to put the idea out.

        Attachments

          Issue Links

            Activity

            Hide
            martinjost Martin Jost added a comment -

            So what is now the behaviour ?
            From what I understand from https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/hudson/tasks/Shell/help-unstableReturn.html:

            • 0: pass (green)
              "The value 0 is ignored and does not make the build unstable to keep the default behaviour consistent."
            • 1: red (fail) ? Or can this also be used for "unstable" ?
            • a configurable value (!= 0) meaning "unstable"
            • What about other exit values ? Will they make the job red ?

            Is it possible to switch the behaviour off (to old behaviour (0:"pass"; all else "fail") to ease transition to the version containing this ?

            Show
            martinjost Martin Jost added a comment - So what is now the behaviour ? From what I understand from https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/hudson/tasks/Shell/help-unstableReturn.html: 0: pass (green) "The value 0 is ignored and does not make the build unstable to keep the default behaviour consistent." 1: red (fail) ? Or can this also be used for "unstable" ? a configurable value (!= 0) meaning "unstable" What about other exit values ? Will they make the job red ? Is it possible to switch the behaviour off (to old behaviour (0:"pass"; all else "fail") to ease transition to the version containing this ?
            Hide
            danielbeck Daniel Beck added a comment -

            Is it possible to switch the behaviour off (to old behaviour (0:"pass"; all else "fail") to ease transition to the version containing this ?

            Quoting the help text, emphasis mine:

            If set, the shell exit code that will be interpreted as an unstable build result.

            Show
            danielbeck Daniel Beck added a comment - Is it possible to switch the behaviour off (to old behaviour (0:"pass"; all else "fail") to ease transition to the version containing this ? Quoting the help text, emphasis mine: If set , the shell exit code that will be interpreted as an unstable build result.
            Hide
            integer Kanstantsin Shautsou added a comment -

            It was pretty easy to change status with touch file and make conditional status change on file.

            If jenkins interprets exit code 2 specially then it crazy regression, already existing jobs may use unstable for deployment, while failed shell script shouldn't provide the way to trigger build.
            http://tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF

            Show
            integer Kanstantsin Shautsou added a comment - It was pretty easy to change status with touch file and make conditional status change on file. If jenkins interprets exit code 2 specially then it crazy regression, already existing jobs may use unstable for deployment, while failed shell script shouldn't provide the way to trigger build. http://tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF
            Hide
            integer Kanstantsin Shautsou added a comment -

            Huh, found that it configurable, hope it disabled by default.

            Show
            integer Kanstantsin Shautsou added a comment - Huh, found that it configurable, hope it disabled by default.
            Hide
            jbochenski Jakub Bochenski added a comment - - edited

            Oleg Nenashev Daniel Beck Craig Ringer can you take a look at JENKINS-47606? I run into problems when trying to use this in a Maven project

            Show
            jbochenski Jakub Bochenski added a comment - - edited Oleg Nenashev Daniel Beck Craig Ringer can you take a look at  JENKINS-47606 ? I run into problems when trying to use this in a Maven project

              People

              • Assignee:
                Unassigned
                Reporter:
                ringerc Craig Ringer
              • Votes:
                11 Vote for this issue
                Watchers:
                17 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: