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

Create a step to set the result of the current stage

XMLWordPrintable

      We would signal/advise Jenkins user that a stage (set of steps) could have some issues. The stage could be unstable, suggesting users to have a look warning messages, or failed, to indicate that, for example, a static analysis was broken. However we would keep the build SUCCESS and deploy artifacts, for all those failure that should not brokes the build.
      One of the reason is also that jenkins build status have impact on bitbucket PR indicator for which unstable means failed build on PR and prevent merge action. There could be softwares that does not provide a wide range of status.

      Actually we have steps `error` and `unstable` to set the current stage and build both to the same result and a message to attach to the stage. To set stage and build differently we have only `catchError` (warnError is sugar syntax).
      We do not like catchError step to be used to set the stage because we have to throw exception (it is also logged on console). So most clean way to set the result of a stage is:

          stage('2') {
              catchError(message: 'Sonar analisys failed', buildResult: 'SUCCESS', stageResult: 'FAILED') {
                error("Sonar analisys failed");
              }
          }
      

      We would introduce a new pipeline step stageResult(result, message) that allow to set the result of the current stage independently from the overall build result.

            nfalco Nikolas Falco
            nfalco Nikolas Falco
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: