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

withCredentials blocked by script approval and errors after approval

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not A Defect
    • Labels:
      None
    • Environment:
      Jenkins 2.150.2
      Credentials binding plugin 1.17
    • Similar Issues:

      Description

      I have a pipeline that uses "withCredentials" to retrieve a secret file and a secret text, like the following:

      pipeline {
          agent none
          (...)
          stages {
              (...)
              stage('Electron builder (win)') {
                  agent {
                      docker {
                          image 'electronuserland/builder:wine'
                          args '-u 0:0'
                      }
                  }
                  steps {
                      script {
                          (...)
                          withCredentials([file(credentialsId: 'code-signing-cert', variable: 'CSC_LINK'), string(credentialsId: 'code-signing-cert-pwd', variable: 'CSC_KEY_PASSWORD')]) {
                              sh "npm run build -- ${environment}"
                          }
                          (...)
                      }
                  }
              }
              (...)
          }
      }

      It was working for maybe 2 or 3 builds, then stopped working with the following error:

      Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (org.codehaus.groovy.runtime.GStringImpl call java.util.LinkedHashMap)

      I noticed this appeared under Manage Jenkins > In-process Script Approval

      I tried to approve it there, and then the "withCredentials" starts failing with the following error:

      groovy.lang.MissingMethodException: No signature of method: java.lang.String.call() is applicable for argument types: (java.util.LinkedHashMap) values: [[credentialsId:code-signing-cert, variable:CSC_LINK]]
      
      Possible solutions: wait(), any(), wait(long), take(int), each(groovy.lang.Closure), any(groovy.lang.Closure)
      

      I'm not sure what I'm doing wrong here and since the exact same piece of code worked before, it looks like a bug to me.

        Attachments

          Activity

          Hide
          tdoubliez Thibault Doubliez added a comment -

          Silly mistake from me, what broke it is that I defined a variable called "file" just before that...

          Closing this ticket.

          Show
          tdoubliez Thibault Doubliez added a comment - Silly mistake from me, what broke it is that I defined a variable called "file" just before that... Closing this ticket.

            People

            • Assignee:
              Unassigned
              Reporter:
              tdoubliez Thibault Doubliez
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: