Jenkins kills process created by Maven test while the tests still runs

6 views
Skip to first unread message

Marc Schlegel

unread,
Aug 13, 2019, 12:23:59 AM8/13/19
to Jenkins Users
Hello everyone.

I've asked this already on the Freenode-IRC, but on second thought this is a better place.

During a Maven test execution my JVM needs to spawn a external process using Javas ProcessBuilder-API. At the end of the test, the process is killed. This works in JUnit standalone, Maven surefire, but not within a Jenkins-Pipelines Maven-step.
I see that the process is started (process console output), but it gets killed within 1 or 2 seconds by something else than my test. The test stores the pid of the started process and uses this pid to get a handle to kill it at the end, but when the test is cleaning up, no process matches the pid (hence I know that something else must have killed it).

As far as I know, the ProcessTreeKiller in Jenkins is responsible for killing processes spawned during job-execution. I thought that the ProcessTreeKiller is only running at the end of each Job. Nevertheless I tried setting JENKINS_NODE_COOKIE=dontkill as well as BUILD_ID=dontkill without avail.
All this happens within a single step:

withMaven(maven: 'maven361', jdk: 'openjdk11') {
  sh "mvn -p integration-test verify"
}

Is there anything in Jenkins which prevents spawning processes from a JVM (Maven)?


For the interested some background: I need to connect to a Kubernetes Pod via TCP which is not possible via Ingress. Hence I need to call "kubectl port-forward" and extract the dynamic allocated port from the process. Thats why my test is in charge of the external process (otherwise I could open it from the pipeline).

best regards
Marc
Reply all
Reply to author
Forward
0 new messages