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

failFast has no effect when withCredentials is used

    XMLWordPrintable

Details

    Description

      When wrapping a long-running step inside a parallel branch in withCredentials, failFast will no longer result in the long-running branch being terminated. I'll use the failFast example at https://github.com/kmadel/jenkins-workflow-examples/blob/master/failFast.groovy:

      This works
      stage 'parallel with failFast'
      def error;
      node {
        try {
          parallel(
            b: { error 'died' },
            // make sure this branch takes longer than b
            a: { sleep 35; writeFile text: '', file: 'a.done' },
            failFast: true
          )
        } catch (e) {
          error = e.toString()
        }
      }
      stage 'failFast Success with error'
      echo "error: ${error}"
      

      That works fine. However, if I try to use withCredentials, the longer-running a branch continues normal execution, and the build only fails once it's done:

      This doesn't work
      stage 'parallel with failFast'
      def error;
      node {
        try {
          parallel(
            b: { error 'died' },
            // make sure this branch takes longer than b
            a: { withCredentials([[$class: 'StringBinding', credentialsId: 'some-credentials-id-here', variable: 'SOME_ENV_VARIABLE']]) {
              sleep 35
              writeFile text: '', file: 'a.done'
            } },
            failFast: true
          )
        } catch (e) {
          error = e.toString()
        }
      }
      stage 'failFast Success with error'
      echo "error: ${error}"
      

      Any ideas what's going on here, or thoughts on a workaround?

      Attachments

        Issue Links

          Activity

            People

              jglick Jesse Glick
              wilkystyle Mike Wilkerson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: