Reputation: 2707
I have build a small Helloworld node application. The idea is to push the code to a Github server which then sends a notification (webhook) to a Jenkins server which will build the code. This part works good. I then also want to deploy the code to a server over SSH every time Jenkins has been building successful. I can't get this step to work.
To be able to deploy the code using SSH, I have written a small shell script (note I have the SSH agent plugin installed and configured correctly a credential with a private key):
#---Contents of /script/deploy-dev.sh---
ssh username@<IP_OF_MY_SERVER> <<EOF
cd ~/HelloWorld
sudo git pull
sudo npm install --production
sudo forever restartall
exit
EOF
I put the following code in the "Execute shell" box (as part of the build)
npm install
./script/test
./script/deploy-dev.sh
The first two lines work well and result in a successfull build. Adding the last line gives me following error message:
Pseudo-terminal will not be allocated because stdin is not a terminal. 02:33:38 sudo: no tty present and no askpass program specified
Any suggestion?
Note: I'm in fact following this tutorial but it suggests to select the 'build when pushed to Github' for which the Github plugin is needed and as this is an enterprise Jenkins I can't add plugins. Only have SSH-agent so would like to use that one
Upvotes: 0
Views: 1442
Reputation: 11854
It looks like you haven't got passwordless sudo configured on the target server. sudo: no tty present and no askpass program specified
is because sudo is requiring a password, but has no way to ask you for it.
Have a look here https://serverfault.com/questions/160581/how-to-setup-passwordless-sudo-on-linux for details on how to set that up.
Upvotes: 1