I have a maven job in Jenkins(version 1.578). The maven snippet (Ant script written in Groovy code) below starts a Fuse server, and I cannot make Jenkins to leave it running after the job finishes.
<profile>
<id>start-fuse</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>start-fuse</id>
<phase>integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
<![CDATA[
def fuseBinDirectory = '${fuse.dir}/bin'
ant.exec(executable:'bash', dir:fuseBinDirectory, failonerror:true, osfamily:'unix') {
ant.env(key:'BUILD_ID',value:'DO_NOT_STOP_MY_PROCESS_JENKINS')
ant.env(key:'KARAF_OPTS',value:'${KARAF_OPTS}')
ant.arg(value:"-c")
ant.arg(value:"nohup ./start ${fuse.start.parameters} </dev/null >> nohup.out 2>&1&")
}
]]>
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
What do I wrong?
How can I fork a similar Fuse process under Windows so that Jenkins does not kill it?
UPDATE - SOLUTION
Adding the 4 env entries mentioned in the accepted answer works both on windows and linux. So no matter which job type you have you can have something like this:
ant.exec(executable:'sh', dir:fuseBinDirectory, failonerror:true, osfamily:'unix') {
ant.env(key:'BUILD_ID',value:'DO_NOT_STOP_MY_PROCESS_JENKINS')
ant.env(key:'HUDSON_SERVER_COOKIE',value:'DO_NOT_STOP_MY_PROCESS_JENKINS')
ant.env(key:'JENKINS_COOKIE',value:'DO_NOT_STOP_MY_PROCESS_JENKINS')
ant.env(key:'JENKINS_SERVER_COOKIE',value:'DO_NOT_STOP_MY_PROCESS_JENKINS')
ant.env(key:'HUDSON_COOKIE',value:'DO_NOT_STOP_MY_PROCESS_JENKINS')
ant.env(key:'KARAF_OPTS',value:'${KARAF_OPTS}')
ant.arg(line:'-c "./start ${fuse.start.parameters}"')
}
Nohup seems to be non neccessary at all.