英文:
How to run jar through jenkins as a separate process?
问题
问题是这样的:我需要在节点上运行一个jar文件,在Jenkins流水线中我写了以下代码
stage('Start bot') {
steps {
sh 'nohup java -jar /home/oomnpe/workspace/oomnpe_bot/target/oomnpe_bot-1.0-jar-with-dependencies.jar'
}
}
但是在启动jar文件后,构建进程无休止地进行下去,显示应用程序的日志,如果向它发送请求的话。如果我停止构建,应用程序也会停止。
如何使jar文件在远程机器上运行并停止构建?到处都写着关于“nohup”的内容,但我使用了它,结果没有。
英文:
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.
答案1
得分: 0
尝试以下内容。查看此问题以获取更多详细信息。
withEnv(['JENKINS_NODE_COOKIE=dontkill']) {
sh "nohup java -jar /home/oomnpe/workspace/oomnpe_bot/target/oomnpe_bot-1.0-jar-with-dependencies.jar &"
}
英文:
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 &"
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论