0

I have created a Jenkins job today, what it does is the Jenkins user should log into another server and run two commands separated by &&:

ssh -i /creds/jenkins jenkins@servername.com "sh -c 'sudo su && lxc exec containername bash'"

The logging part works fine, then it runs the sudo su command and becomes root but it never runs the second command.

I even did this manually and from the Jenkins machine logged into the other server (servername). Then ran sh -c "sudo su && lxc exec containername bash" with no luck.

Avihoo Mamka
  • 4,656
  • 3
  • 31
  • 44
Irina
  • 21
  • 2

1 Answers1

1

Try to execute the second command as a parameter for the sudo su command, like this:

ssh -i /creds/jenkins jenkins@servername.com "sh -c 'sudo su -c "lxc exec containername bash"'"
Avihoo Mamka
  • 4,656
  • 3
  • 31
  • 44