Deploy Jar to remote server from Jenkins Build Job

问题: I currently have a Jenkins job that does the following successfully: 1: Check for new commits in git repo ✓ 2: clone repo ✓ 3: Build repo jar with maven ✓ 4: scp jar to r...

问题:

I currently have a Jenkins job that does the following successfully:

1: Check for new commits in git repo ✓
2: clone repo ✓
3: Build repo jar with maven ✓
4: scp jar to remote server ✓

The 5th step is to run the jar, I am currently doing something like:

nohup ssh user@remotehost "java -jar some.jar" > /dev/null 2>&1 

This works technically, it will run the jar, however the jenkins job is not finishing, I assume it is waiting for an exit code.

What I wish to achieve is, fire a command to a remote server over ssh without waiting for a response or output. I'm not sure if this is possible, is there a better way to do this?


回答1:

You can try using the screen command:

screen -d -m ssh user@remote "java -jar -Dserver.port=9090 ~/jar.jar"

From manual:

-d -m Start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.

  • 发表于 2019-12-25 21:11
  • 阅读 ( 199 )
  • 分类:网络文章

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除