一、啟動tomcat
來源:
http://blog.csdn.net/prisonbreak_/article/details/50749576(給出方法)
http://veryyoung.me/blog/2016/04/19/jenkins-backgroud-process.html(給出方法+解釋原因)
在網上查了資料,需要在執行指令碼之前加入:export BUILD_ID=XXXXXX
XXXXX可以隨便寫的什麼
具體原因還不知道,以後研究了,再來補充。
這裡我就來補充一下咯(又是我copy的):
今天在配置 Jenkins Job 的時候,after mvn package 用命令列 nohup java -jar project-1.0-SNAPSHOT.jar > server.log 2>&1 & 起一個 spring-boot 專案,死活不生效。
ssh 到伺服器上查不到對應的程式,而直接在伺服器上執行是完全 OK 的。
Google 一番後得知,這是 Jenkins 的特性。
To reliably kill processes spawned by a job during a build, Jenkins contains a bit of native code to list up such processes and kill them. This is tested on several platforms and architectures, but if you find a show-stopper problem because of this, you can disable this feature by setting a Java property named “hudson.util.ProcessTree.disable” to the value “true”. This can be done as a parameter to the “java” binary when starting Jenkins:
`java -Dhudson.util.ProcessTree.disable=true -jar jenkins.war`
The ProcessTreeKiller takes advantage of the fact that by default a new process gets a copy of the environment variables of its spawning/creating process.It sets a specific environment variable in the process executing the build job. Later, when the user requests to stop the build job’s process it gets a list of all processes running on the computer and their environment variables, and looks for the environment variable that it initially set for the build job’s process.
具體連結請點選 ProcessTreeKiller。
大概意思是 Jenkins 是在啟動 Job 的時候會給子程式設定環境變數,在結束 Job 的時候會檢查程式的環境變數,如果包含 Jenkins 生成的,kill 掉。
解決方案:
啟動 Jenkins 的時候加上 -Dhudson.util.ProcessTree.disable=true,也就是 java -Dhudson.util.ProcessTree.disable=true -jar jenkins.war
在後臺程式前加上 BUILD_ID=dontKillMe, 也就是 BUILD_ID=dontKillMe nohup java -jar project-1.0-SNAPSHOT.jar > server.log 2>&1 &
二、maven構建的時候忽略Javadoc
maven構建的時候,忽略Javadoc可以加快速度
mvn clean package -D maven.javadoc.skip=true