sudo su with password provided in jenkins?

I am stuck with one requirement in which I am switching to some "xxx" user and it asks for password every time. I am trying to automate this process with password hardcoded in Jenkins job. ex: sudo su - "xxx" password should be given in Jenkins job

Can anyone provide some solution code?

Thanks, sp_devops

1

1 Answer

Really the best way to do this would be to ask your Jenkins administrator to add sudoers permissions to allow Jenkins to login and run commands as the other user.

Beyond that, your best bet would be to store the username and password in Jenkins' built-in credentials store and use the withCredentials step in your Jenkinsfile to authenticate as the other user.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like