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

Declarative credentials() can't see user store credentials

XMLWordPrintable

      I tried using string parameter with declarative where user types in their user store credential id but then declarative 'credentials' DSL failed to find it. Below is sample script where 'my-user-cred' is credential id created in user credentials store.
       

      pipeline{
        agent any
        environment { 
          USER_CRED = credentials('my-user-cred') 
        }
        stages {
          stage('Example') {
            steps {
              sh 'echo ${USER_CRED}'
            }
          }
        }
      }
      
      

       
       It fails with:

      org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: my-user-cred
      at org.jenkinsci.plugins.pipeline.modeldefinition.model.CredentialsBindingHandler.forId(CredentialsBindingHandler.java:121)
      at org.jenkinsci.plugins.pipeline.modeldefinition.model.CredentialsBindingHandler$forId.call(Unknown Source)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
      at 
      

            abayer Andrew Bayer
            vivek Vivek Pandey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: