1

I have to create a Pipeline from the Jenkins 'master' which execute a batch as a specific user on a slave machine.

In the following example:
The slave machine is identified as 'my_node'. Jenkins 'master' contains a username/password credential called 'my_id'. I pass the credentials to my batch with the variables $USER and $USERPASS

node('my_node') {
   stage("exec") {
      withCredentials([usernamePassword(credentialsId: 'my_id', usernameVariable: 'USER', passwordVariable: 'USERPASS')]) {
         bat "runas /savecred /user:MY_DOMAIN\\$USER /password:$USERPASS \"cmd\""
      }
   }
}

But when I execute the pipeline, the result are the following:

C:\my_workspace>runas /savecred /user:MY_DOMAIN\**** /password:**** "cmd" 
Enter the password for MY_DOMAIN\****: 
script returned exit code 1

It is possible to override the password prompt during the pipeline execution ?

3
  • 1
    I believe this question better fits either devops or superuser community.
    – Alexey R.
    Jul 19, 2018 at 18:39
  • Thanks, i will duplicate this question in 'devops' community
    – Marsso
    Jul 20, 2018 at 13:28
  • Did you find a solution? I've been in same situation. Aug 26, 2021 at 23:33

1 Answer 1

-1

I do also have same issue any inputs appreciated.

My case is running BDD test cases as part of Pipeline

node('my_node') { stage("exec") { withCredentials([usernamePassword(credentialsId: 'my_id', usernameVariable: 'USER', passwordVariable: 'USERPASS')]) {

     bat "%NUGET_PACKAGES%/nunit.consolerunner/3.11.1/tools/nunit3-console.exe"
  }

} }

i should run bat "%NUGET_PACKAGES%/nunit.consolerunner/3.11.1/tools/nunit3-console.exe with different user. Thanks

1
  • 1
    Please do not post "I'm having a similar issue" questions as an answer. You could ask this as a separate question with a link to the original question and an explanation of how your problem is different, or you could upvote the original question. Please see sqa.stackexchange.com/help/how-to-answer for more information.
    – Kate Paulk
    Sep 15, 2021 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.