Details
-
Bug
-
Status: Resolved (View Workflow)
-
Major
-
Resolution: Fixed
Description
It's possible to look-up User-scoped credentials in Freestyle jobs with Bindings. The same seems not to work in pipeline jobs.
node { withCredentials([[$class : 'UsernamePasswordMultiBinding', credentialsId: 'bc047678-37b8-4747-95d8-c1a8b3df51a6', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { echo "${env.USERNAME}" } }
org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: bc047678-37b8-4747-95d8-c1a8b3df51a6 at org.jenkinsci.plugins.credentialsbinding.MultiBinding.getCredentials(MultiBinding.java:124) at org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding.bind(UsernamePasswordMultiBinding.java:68) at org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Execution.start(BindingStep.java:92)
Plugin versions:
credentials-binding: 1.9
credentials: 2.1.5
Attachments
Issue Links
- is related to
-
JENKINS-44772 User Scoped credentials are not used by the "withCredentials" pipeline step
-
- Open
-
-
JENKINS-47699 Cannot use user-scoped credentials from pipeline input step parameters
-
- Resolved
-
- relates to
-
JENKINS-44774 User Scoped credentials don't appear in credentials drop down lists
-
- Resolved
-
-
JENKINS-58170 Allow credential parameters to shadow credential ids in lookup
-
- Resolved
-
- links to
(1 links to)
stephenconnolly's method #2 does seem to work for me. Here's an example pipeline.
Note that the single quotes around '${creds_param}' is not a mistake. The CredentialsProvider.findCredentalById method specifically looks to see if the id starts with ${ and ends with }. See https://github.com/jenkinsci/credentials-plugin/blob/master/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java#L882
This makes it so user creds selected as build params work in the withCredentials pipeline step. That's not really enough for my problems because I want to use parameters from an input step, but that's maybe a different issue. Thought I'd share this.