Reputation: 7320
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
b) java -jar serverLaunch.jar &>/dev/null &
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.
Upvotes: 0
Views: 6428
Reputation: 119
Another effective approach would be to add a post-build action that executes a shell spawning the server.
Upvotes: -1
Reputation: 7320
I had to check "Inject environment variables to the build process" and add:
BUILD_ID=dontKillMe
Now it is working.
Upvotes: 6
Reputation: 4149
Try using nohup e.g.:
nohup java -jar serverLaunch.jar &
That should prevent the process being terminated when the parent shell process exits (which I suspect is your problem).
Upvotes: -1