spring-boot - Run a springboot jar with Jenkins Build command
问题描述
I am trying to automate a SpringBoot Application
through Jenkins
.
I have myApp.jar
and currently, I run it using the following command
nohup java -jar myApp.jar &
Press Ctrl^C
or Ctrl^Z
and process keep running in the background.
Logs will be added in nohup.out
Now I want the same process to be done using Jenkins.
In Jenkins, build section, I have selected Execute Shell Script with the above command.
When build is triggered. I can see Application startup Log in Jenkins Log but the problem is, build never finishes.
I have tried
BUILD_ID=dontKillMe timeout --foreground 30 nohup java -jar website-status.jar &
also
BUILD_ID=dontKillMe nohup java -jar website-status.jar &
timeout
is killing the process. I don't want process to be killed.
Edit 1:
I have tried this as well. Build keeps running.
JENKINS_NODE_COOKIE=dontKillMe nohup java -jar website-status.jar &
解决方案
When we execute command like this
nohup java -jar myApp.jar &
a prompt is shown saying log will be written in nohup.out
file and this was causing the script to hang forever in Jenkins.
I changed the command and now no prompt and works fine, logs are written in server.log
nohup java -jar myApp.jar >> server.log 2>&1&
推荐阅读
- javascript - jsonschema 未在缺少必需属性时引发错误
- arrays - 从集合视图中的数组中抓取字符串时超出索引范围
- c# - 如何将带有动态查询参数的 PowerBI 报告 url 加载到 mvc 网站中
- c# - 在没有存储过程的情况下从 C# Visual Studio 执行 Alter Tablespace 语句
- git - 在 Windows 上使用 SSH 私钥进行 Git 推送
- python - what's the necessity of "else" in Python exception handling?
- apache-spark-sql - 在 Spark 中创建数据框时遇到问题
- ionic-framework - cordova-plugin-antplus 不适用于 ionic 3
- c# - 是否可以在 .NET 中开发大型应用程序(企业级)?
- jquery - 使用jquery隐藏首页上的导航栏