Use of withCredential on Slave Node

18 views
Skip to first unread message

bearrito

unread,
Apr 26, 2018, 11:28:10 AM4/26/18
to Jenkins Users
The premable to my Jenkinsfile looks like

try {

    node("linux") {

      withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'REDACTED',
        usernameVariable: 'REDACTED_USER', passwordVariable: 'REDACTED_PASSWORD']]) {



When I run the job without the node label, everything works fine, as it runs on Master.With the node specification I get a failure related to failed auth.

My general question is do I need to do anything to make the credentials plugin work with slave nodes?



Ramanathan Muthaiah

unread,
Apr 27, 2018, 4:38:52 AM4/27/18
to Jenkins Users
I don't think any special handling is needed in the build agent.

Can you try this in your pipeline script ?

withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'jiracreds', usernameVariable: 'JIRAUser', passwordVariable: 'JIRAPwd']]) {
     withEnv(["JIRA_USERNAME=${JIRAUser}",
                 "JIRA_PASSWORD=${JIRAPwd}",
                 "JIRA_TICKET=${item}"]) {
                        <build-script-can-use-the-env-vars>
       }
 }

/Ram 
Reply all
Reply to author
Forward
0 new messages