Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
How can I run shell commands on another server from Jenkins service?

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

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

 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
  1. Sometimes when connecting through ssh tunnel, changing directory can cause premission access problems, so first connect to server than change directory.
  2. StrictHostKeyChecking=no: The option StrictHostKeyChecking specifies whether or not ssh will automatically add new host keys to the $HOME/.ssh/known_hosts file, or never automatically add new host keys to the host file. This option, when set to yes, provides maximum protection against Trojan horse attacks.
  3. <<EOF - End of line, used for multi-line shell command.
  4. cd backend - changes directory to backend after connectiong to server.
  5. echo: Prints a string to know when this process is finnished.
  6. exit: to exit out of server's shell
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda