patternMajor
Running a background process in Pipeline job
Viewed 0 times
backgroundprocessrunningjobpipeline
Problem
I am looking for a way to run a java process in background using Jenkins declarative pipeline. Below is the snippet of code
Already aware of ProcessTreeKiller of Jenkins and every answer suggest to do the same. I have tried using environment inside the steps block with no luck.
Jenkins version : 2.60.1
Pipeline plugin : 1.1.7
Any help is greatly appreciated.
stage('Deploy'){
steps{
script{
withEnv(['BUILD_ID=dontkill']) {
sh "nohup java -jar test-0.0.1-SNAPSHOT.war &"
}
}
}
}Already aware of ProcessTreeKiller of Jenkins and every answer suggest to do the same. I have tried using environment inside the steps block with no luck.
Jenkins version : 2.60.1
Pipeline plugin : 1.1.7
Any help is greatly appreciated.
Solution
Any one facing the same problem and using pipeline project, set
Dont waste your time setting
Refer to https://issues.jenkins-ci.org/browse/JENKINS-28182 for more details.
JENKINS_NODE_COOKIE instead of BUILD_ID.Dont waste your time setting
HUDSON_COOKIE, HUDSON_SERVER_COOKIE, JENKINS_COOKIE or JENKINS_SERVER_COOKIE. None of them work for pipeline project.Refer to https://issues.jenkins-ci.org/browse/JENKINS-28182 for more details.
Context
StackExchange DevOps Q#1473, answer score: 21
Revisions (0)
No revisions yet.