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
11 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.