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

withCredentials hangs

XMLWordPrintable

    • workflow-cps 2.76

      On Jenkins 2.176.2 and credentials-binding-plugin 1.19, the following pipeline will intermittently hang:

      pipeline {
          agent any
      
          stages {
              stage('bug') {
                  steps {
                      script {
                          for (int i = 0; i < 100; i++) {
                              withEnv(['A=b']) {
                                  withCredentials([]) {
                                      sh "echo hello ${i}"
                                  }
                              }
                          }
                      }
                  }
              }
          }
      }
      

      The build log looks like this:

      ...
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] withCredentials
      

      until the build is aborted.

      I've seen two independent things that both seem to work around the problem:

      • flipping so `withCredentials([])` wraps `withEnv([...])` seems to avoid the hang.
      • ensuring there's always at least one item in the `withCredentials` list parameter seems to avoid the hang.

      We run into this in a pipeline where the parameter to withCredentials varies by projects, and sometimes is an empty list.

            dnusbaum Devin Nusbaum
            jonathanb1 Jonathan B
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: