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

[Pipeline] Pipeline step to exit the build immediately as a success

      It would be convenient if there was a pipeline step that would exit the run immediately, but not have it be necessarily be a failure.

      This would be useful in situations where a run determines it no longer has work to do, and so it should end immediately as success (or whatever the current result state is).
      If we have multiple such decision points in a build, doing this with conditionals gets incredibly messy quite quickly.

          [JENKINS-41197] [Pipeline] Pipeline step to exit the build immediately as a success

          Jesse Glick added a comment -

          For now, assuming you are inside the main script body:

          return
          

          Jesse Glick added a comment - For now, assuming you are inside the main script body: return

          jglickreturn only gets out of the current closure, unless you meant I have to be outside of any pipeline step block

          node {
              withEnv(["a=b"]) {
                  return
              }
              println "endenv"
          }
          println "endnode"
          

          this will print out both "endenv" and "endnode"

          Sean Sutherland added a comment - jglick return only gets out of the current closure, unless you meant I have to be outside of any pipeline step block node { withEnv([ "a=b" ]) { return } println "endenv" } println "endnode" this will print out both "endenv" and "endnode"

          Jesse Glick added a comment -

          Yeah, in general you may need to throw and catch something.

          Jesse Glick added a comment - Yeah, in general you may need to throw and catch something.

          J Knurek added a comment -

          jglick

          Yeah, in general you may need to throw and catch something.

          But that's exactly the point of this feature request:

          If we have multiple such decision points in a build, doing this with conditionals gets incredibly messy quite quickly.

          I don't think this is resolved, we only have workarounds until this feature is created. 


          I don't know how the error step is implemented, but it might be nice to change it to an exit step in which the error code can be added/removed as an option 

          J Knurek added a comment - jglick Yeah, in general you may need to throw and catch something. But that's exactly the point of this feature request: If we have multiple such decision points in a build, doing this with conditionals gets incredibly messy quite quickly. I don't think this is resolved, we only have workarounds until this feature is created.  I don't know how the error step is implemented, but it might be nice to change it to an exit step in which the error code can be added/removed as an option 

          Jesse Glick added a comment -

          I don't think this is resolved, we only have workarounds

          That is why it is resolved as a duplicate.

          Jesse Glick added a comment - I don't think this is resolved, we only have workarounds That is why it is resolved as a duplicate .

          J Knurek added a comment -

          oops, sorry. I saw the duplicate but thought it was the other way around - my bad

          J Knurek added a comment - oops, sorry. I saw the duplicate but thought it was the other way around - my bad

            Unassigned Unassigned
            ssutherland Sean Sutherland
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: