0

I want to make job on Jenkins that starts server (MockServer on WireMock).

Server is launched from *.jar file, from terminal like that.

java -jar serverLaunch.jar

It takes over my console. To avoid that I modify this and do:

java -jar serverLaunch.jar &>/dev/null &

And that works for me on my local PC. Now I want to move it to Jenkins.

If I try to do this from "Shell command" block in Jenkins Job then:

a) java -jar serverLaunch.jar

  • I have task locked in queue in my Jenkins and I don't want that but server starts and works.

b) java -jar serverLaunch.jar &>/dev/null &

  • Job ends with success but my server is not alive.

I have wrapped this command also in .sh script and .rb script. Any idea how to make it work?


I've tried this: https://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build

And then in Jenkins "Shell script":

daemonize -E BUILD_ID=dontKillMe /bin/bash launch.sh

But it also passes but server is not alive.

4

3 回答 3

5

我必须检查“将环境变量注入构建过程”并添加:

BUILD_ID=dontKillMe

现在它正在工作。

于 2016-11-24T08:43:09.630 回答
-1

尝试使用 nohup 例如: nohup java -jar serverLaunch.jar &

这应该可以防止在父 shell 进程退出时终止进程(我怀疑这是你的问题)。

于 2016-11-22T21:23:05.527 回答
-1

另一种有效的方法是添加一个构建后操作,该操作执行一个生成服务器的 shell。

于 2018-02-16T12:24:56.247 回答