The question is this: I need to run a jar file on the node, in the Jenkins pipeline I write
stage('Start bot') {
steps {
sh 'nohup java -jar /home/oomnpe/workspace/oomnpe_bot/target/oomnpe_bot-1.0-jar-with-dependencies.jar'
}
}
But the build goes on endlessly after launching the jar, showing the logs of the application, if you make requests to it. If I stop the build, then the application also stops.
How to make the jar run on the remote machine and the build stop? Everywhere they write about "nohup", but I use it and there is no result.
Try the following. Check this issue for more details.
withEnv(['JENKINS_NODE_COOKIE=dontkill']) {
sh "nohup java -jar /home/oomnpe/workspace/oomnpe_bot/target/oomnpe_bot-1.0-jar-with-dependencies.jar &"
}