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

Pipeline build step should produce an informative exception on build failure

XMLWordPrintable

      Currently, when using build and the invoked build fails, a FlowInterruptedException(null) is thrown.  This exception has a null message and cause.  Additional acrobatics are necessary to add something informative in the invoking build (ie calling handle() with a listener or switching to propagate: false and interrogating the resulting object).

       

      This is especially inconvenient when a pipeline triggers multiple builds, as it is not easy to determine which one failed (even worse when using parallel).

       

      My current workaround is to use my own shared var wrapper instead of build:

      /**
       * same as DSL's "build", but produces a neat exception on failure that we can actually use
       * (as opposed to a FlowInterruptedException(null))
       */
      def buildAndWait(Map config) {
          def buildResult = build(config + [propagate: false])
          if (buildResult.resultIsWorseOrEqualTo('UNSTABLE')) {
              error "Build ${buildResult.projectName}#${buildResult.number}: ${buildResult.result}"
          }
      }

      Ideally, build would throw a more informative exception so that I don't need the above.

      I am using exceptions in my scripted pipelines to drive automatic notifications, and, since many different parts of the build can fail, it's very helpful to know at a glance what the cause was.

            Unassigned Unassigned
            akom Alexander Komarov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: