jenkins nohup 不起作用问题处理

原答案:  https://issues.jenkins.io/browse/JENKINS-60593

还有一种可能是 .bashrc 没有配置环境变量



export JAVA_HOME=/usr/local/jdk/amazon-corretto-8.282.08.1-linux-x64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH

 

  

 

 

OK, I got something working.

I have a script file on the remote server with this:

nohup java -jar demo.jar > nohup.out &
sleep 5

It's the sleep 5 that fixed it for me. Now in my pipeline script I have:

sshPut remote: remote, from: 'target/demo.jar', into: 'demo.jar'
sshCommand remote: remote, command: './script.sh'

This works. I guess maybe the sshCommand finishes so fast it closes the connection before nohup can really start? Just a guess, I'm not a Linux guy.

I also tried sshCommand remote: remote, command: 'nohup java -jar demo.jar > nohup.out & && sleep 5', but that didn't work, and neither did nohup java -jar demo.jar > nohup.out & ; sleep 5. In both cases it results in a "Failed command error".

posted on 2022-10-11 14:17  正义的伙伴!  阅读(354)  评论(0编辑  收藏  举报

导航

//增加一段JS脚本,为目录生成使用