Use of personal credentials in Jenkins Pipeline (Declarative)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Use of personal credentials in Jenkins Pipeline (Declarative)

drew.leske
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.



--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4a246c6b-988c-4987-8da7-93bf193e8614%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Use of personal credentials in Jenkins Pipeline (Declarative)

James Dumay
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 

On Saturday, July 15, 2017 at 5:28:21 AM UTC+10, [hidden email] wrote:
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: <a href="https://issues.jenkins-ci.org/browse/JENKINS-32417" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-32417\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGSybynUKHQSFu4fLmx50i798WkNQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-32417\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGSybynUKHQSFu4fLmx50i798WkNQ&#39;;return true;">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.



--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/02349215-b962-4c07-b4f5-48ed15a92a86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...