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

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

      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.

          [JENKINS-23786] Permit "Execute shell" jobs to return 2 for "unstable"

          Craig Ringer created issue -

          Daniel Beck added a comment -

          This should be fairly trivial to add. Unfortunately arbitrary tools may use that exit code to indicate failure, just like exist code 1, or 5, or anything non-zero, and starting to mark builds as unstable (and continue execution!) is a very backwards incompatible change, so won't be added.

          The only compatible solution I could think of would be an 'Advanced' option to designate specific exit codes for a shell script/batch file builder to indicate 'Unstable'.

          Daniel Beck added a comment - This should be fairly trivial to add. Unfortunately arbitrary tools may use that exit code to indicate failure, just like exist code 1, or 5, or anything non-zero, and starting to mark builds as unstable (and continue execution!) is a very backwards incompatible change, so won't be added. The only compatible solution I could think of would be an 'Advanced' option to designate specific exit codes for a shell script/batch file builder to indicate 'Unstable'.

          Craig Ringer added a comment -

          Indeed - I'd assumed that'd have to be the case, which means adding new UI in an unfamiliar declarative UI generator. Fun. I'll have a look and see what's involved.

          Craig Ringer added a comment - Indeed - I'd assumed that'd have to be the case, which means adding new UI in an unfamiliar declarative UI generator. Fun. I'll have a look and see what's involved.

          Craig Ringer added a comment -

          ./core/src/main/java/hudson/tasks/CommandInterpreter.java already has an extension point for this, join(Proc p), but it's incomplete. See JENKINS-23896 .

          Craig Ringer added a comment - ./core/src/main/java/hudson/tasks/CommandInterpreter.java already has an extension point for this, join(Proc p), but it's incomplete. See JENKINS-23896 .

          Craig Ringer added a comment -

          Depends on the fix in JENKINS-23896 for access to the Build object

          Craig Ringer added a comment - Depends on the fix in JENKINS-23896 for access to the Build object
          Craig Ringer made changes -
          Link New: This issue is related to JENKINS-23896 [ JENKINS-23896 ]

          Craig Ringer added a comment -

          Craig Ringer added a comment - Created pull https://github.com/jenkinsci/jenkins/pull/1325 for this.
          Craig Ringer made changes -
          Labels Original: shell unstable New: patch pull_request shell unstable
          Craig Ringer made changes -
          Link Original: This issue is related to JENKINS-23896 [ JENKINS-23896 ]

          Craig Ringer added a comment -

          Requires the fix in JENKINS-23896 . Merge that first.

          Craig Ringer added a comment - Requires the fix in JENKINS-23896 . Merge that first.
          Craig Ringer made changes -
          Link New: This issue depends on JENKINS-23896 [ JENKINS-23896 ]

            Unassigned Unassigned
            ringerc Craig Ringer
            Votes:
            11 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved: