如何叉詹​​金斯后台进程?设置BUILD_ID和使用的nohup似乎非工作 [英] How to fork a background process in Jenkins? Setting BUILD_ID and using nohup seems to be non working

查看:222
本文介绍了如何叉詹​​金斯后台进程?设置BUILD_ID和使用的nohup似乎非工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在詹金斯一个maven作业(1.578版)。下面的代码片段的Maven(Groovy写code Ant脚本)开始的保险丝服务器,我不能让詹金斯离开它运行在作业结束后。

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>

什么我错了?

我如何叉在Windows下一个类似的保险丝过程,使詹金斯不杀呢?

How can I fork a similar Fuse process under Windows so that Jenkins does not kill it?

添加在接受的答案都提到工作在Windows和Linux的4 ENV条目。所以,无论你有作业类型可以有这样的事情:

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似乎非neccessary在所有

Nohup seems to be non neccessary at all.

推荐答案

如果你会发现用户MDP中的这个页面,你会发现,在工作情况下使用自由泳模板创建,BUILD_ID确实工作。有很多谁遇到类似的问题,等等。这些问题只能被视为当它是一个非自由泳的工作。

If you will notice the comment by user 'mdp' in this page, you will notice that in case of jobs created using freestyle template, BUILD_ID does work. There are many others who faced similar issue. Such issues were seen only when it was a non-freestyle job.

另外,还应检查取消设置以下变量:在的链接。

Alternatively, should also check unsetting the following variables: HUDSON_COOKIE, HUDSON_SERVER_COOKIE, JENKINS_COOKIE or JENKINS_SERVER_COOKIE as suggested by few (Comments section) in this link.

这篇关于如何叉詹​​金斯后台进程?设置BUILD_ID和使用的nohup似乎非工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆