Reputation:
I have a node project with pm2 I want to create a shell script on Jenkins to triger the build I have watched a lot of tutorials but i cant seem to find any good way to fix the problem.
Here is what I have tried
ssh -tt -i privKey username@ip/backend
npm install
node server.js
Here what I need to do
1.Connect to the server
2.Run npm install
3.Reload pm2.json
But the shell script is failing to connect to the server and to run the script
Upvotes: 0
Views: 343
Reputation: 850
ssh -o StrictHostKeyChecking=no -tt -i privKey username@ip <<EOF
cd backend
npm install
node server.js
pm2 reload pm2.json
echo 'Process completed successfully.'
exit
EOF
Upvotes: 2