Use of personal credentials in Jenkins Pipeline (Declarative)

1,103 views
Skip to first unread message

drew....@computecanada.ca

unread,
Jul 14, 2017, 3:28:21 PM7/14/17
to Jenkins Users
Hi all,

I would like to be able to use a personal credential in Jenkins for a Pipeline build, and there does not appear to be a way to do this.  My first attempt was to call `credentials('cred-id')` but this fails in the build with `org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: 'cred-id'`. I then found this issue in Jira: https://issues.jenkins-ci.org/browse/JENKINS-32417.  The explanation given in closing the ticket:

Indeed after some reasoning this looked as a not-a-defect since personal credentials should not appear in a job configuration. Personal credentials, as opposite, correctly appear if the build is parametrised with a credential parameter: when building a job you can successfully select the credentials belonging to your user.

Fair enough.  I then attempted to make the build a parameterized build with the credentials selectable on build initiation.  Say I have one set up to take a credential as a parameter and then provide this to the pipeline.  This leads to syntax errors in the build:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 10: Internal function call parameters must be strings. @ line 10, column 26.
           CREDS = credentials(env.LOGIN)

I can access $LOGIN through the pipeline in a script block, but it does not appear I can make use of it with `credentials()`.  Even if I could I believe it would just have the exact same problem as by explicitly naming the credential in the pipeline, because the parametrized build does not expose the credentials, just the ID.

Is it possible to use personal credentials with declarative pipeline?

Thanks,
Drew.



James Dumay

unread,
Jul 16, 2017, 10:39:10 PM7/16/17
to Jenkins Users
Hi Drew,

There is a big of a gap in capabilities for when and where personal credentials could be used within the Pipeline. Its near the top of the list of things to have our Pipeline team at CloudBees fix soon.

You can watch and vote for this ticket JENKINS-38963 

drew....@computecanada.ca

unread,
Jul 24, 2017, 6:00:37 PM7/24/17
to Jenkins Users
Hi James,

Thank you for your response.  Even if it's not the answer I was looking for, a clear response is helpful. :)

I'll vote for and watch the ticket.  Cheers,
Drew.
Reply all
Reply to author
Forward
0 new messages