根据下面介绍,合适的解决方案是:
BUILD_ID=dontKillMe bash /home/app/opt/apache-tomcat-6.0.37/deploy-bin/deploy_test.sh
----------------
最近用jenkins执行服务器上的脚本,启动tomcat总是不成功,问了谷哥之后,发现是下面一个特性在作怪:
http://wiki.hudson-ci.org/display/HUDSON/ProcessTreeKiller
|
This feature is available since 1.260 |
To reliably kill processes spawned by a job during a build, Hudson contains a bit of native code to list up such processes and kill them. This is tested on several platforms and architectures, but if you find a show-stopper problem because of this, you can disable this feature by setting a Java property named "hudson.util.ProcessTreeKiller.disable" to the value "true".
This can be done as a parameter to the "java" binary when starting Hudson:
java -Dhudson.util.ProcessTreeKiller.disable=true -jar hudson.war
Depending on how you run your container, this can be different. In the distributed build environment, this system property needs to be set on slave JVMs.
How it works
The ProcessTreeKiller takes advantage of the fact that by default a new process gets a copy of the environment variables of its spawning/creating process.
It sets a specific environment variable in the process executing the build job. Later, when the user requests to stop the build job's process it gets a list of all processes running on the computer and their environment variables, and looks for the environment variable that it initially set for the build job's process.
Every job with that environment variable in its environment is then terminated.
If your build wants to leave a daemon running behind...
A convenient way to achieve that is to change the environment variable BUILD_ID which Hudson's ProcessTreeKiller is looking for. This will cause Hudson to assume that your daemon is not spawned by the Hudson build. For example:
BUILD_ID=dontKillMe /usr/apache/bin/httpd
---------------------
来自stackoverflow的问答:
http://stackoverflow.com/questions/5728899/tomcat-script-not-working-when-run-from-hudson
http://stackoverflow.com/questions/7703156/start-up-tomcat-from-ant-script
----------------------
The problem had to do with Jenkins feature called ProcessTreeKiller
described here.
Basically Jenkins automatically kills all processes spawned by a job by searching the process tree for processes with specific environment variable
All i had to do was to overwrite jenkins env variable called BUILD ID
and it worked. I used a Setenv Plugin to set the env var specific for the build.
-----
What about executing the command like this :
<execexecutable="bash"><argvalue="-c"/><argvalue='nohup ${tomcat.bin.dir}/startup.sh -Xms128M -Xmx512M &'/></exec>
---
uild.properties file:
#----------------------------------------------------
#Tomcat Configuration
#----------------------------------------------------
#Back-end Tomcat
tomcat.dir=${branch.dir}/../tomcat
tomcat.bin.dir=${tomcat.dir}/bin
tomcat.bootstrap.jar=${tomcat.bin.dir}/bootstrap.jar
tomcat.jvmarg=-Dcatalina.home
loadproperties file
<propertyfile="${basedir}/build.properties"/><!-- Stop tomcat --><targetname="stop-tomcat"description="Stops back-end tomcat server"depends="prepare"><javajar="${tomcat.bootstrap.jar}"fork="true"spawn="false"><jvmargvalue="${tomcat.jvmarg}=${tomcat.dir}"/><argline="${arg.stop}"/></java><echo>+---------------------------------+</echo><echo>| T O M C A T S T O P P E D |</echo><echo>+---------------------------------+</echo></target>
Also I have added an element called spawn set to "false", which print execution output onto console.
Hope this helps :)
相关推荐
jenkins压缩包,jdk8,jenkins.war以及Jenkins安装及配置的pdf
jdk1.8支持的最后一个版本jenkins,验证可用Jenkins Jenkins 2.289.3 jenkins.msi jdk1.8支持的最后一个版本jenkins,验证可用Jenkins Jenkins 2.289.3 jenkins.msi jdk1.8支持的最后一个版本jenkins,验证可用...
jdk1.8支持的最后一个版本jenkins,验证可用Jenkins 2.346.1 jenkins.msi jdk1.8支持的最后一个版本jenkins,验证可用Jenkins 2.346.1 jenkins.msi jdk1.8支持的最后一个版本jenkins,验证可用Jenkins 2.346.1 ...
《Jenkins权威指南》从实践者的角度,在讲解Jenkins基本原理的同时,深入到持续集成、持续交付领域,为读者梳理出如何使用Jenkins设计和实现一个自动化的、周期性的集成测试过程,帮助读者理解Jenkins适用于什么场景...
因为Jenkins是使用Java编写的,所以需要安装Java环境 1、安装OpenJDK。 sudo dnf install java-1.8.0-openjdk-devel 2、启用Jenkins存储库。运行以下命令下载并导入GPG密钥 sudo wget -O /etc/yum.repos.d/jenkins....
jenkins老版本资源
内容概要:由于Jenkins版本和插件更替较快,当我们下载插件时,提示我们需要升级Jenkins版本,而又不想对Jenkins版本进行升级,所以就导致部分插件无法安装,当然我们也可以去官网下载对应版本,但是插件之间的项目...
jenkins.war jenkins ci
linux离线安装jenkins插件安装包,包含jenkins.war, jenkins-plugins等hpi文件。
jenkins发版报错Host key verification failed. jenkins发版报错Host key verification failed. jenkins发版报错Host key verification failed. jenkins发版报错Host key verification failed. jenkins发版报错Host ...
jenkins配置jenkins配置jenkins配置
本插件库不可以单独使用,需要配合的`.jenkins`文件夹(该文件夹为Jenkins启动时自动生成的)使用,具体使用步骤如下: 1,正常通过war包或者其他的方式启动Jenkins; 2,找到Jenkins生成的工作目录`.jenkins`,查看...
Design, implement, and execute continuous delivery pipelines with a level of flexibility, control, and ease of maintenance that was not possible with Jenkins before. With this practical book, build ...
Jenkins-邮件模板。jenkins代码构建邮件通知模板 ,不管成功失败都可以
If you want to get up and running with Jenkins, see Installing Jenkins for procedures on how to install Jenkins on your supported platform of choice. If you are a typical Jenkins user (of any skill ...
Jenkins入门系列之——Jenkins安装与配置 2 Jenkins安装 在最简单的情况下,Jenkins 只需要两个步骤: 1.下载最新的版本(一个 WAR 文件)。Jenkins官方网址: http://Jenkins-ci.org/ 2.运行 Java -jar jenkins....
jenkins安装包 jenkins安装包 jenkins安装包 jenkins安装包
将压缩文件解压到/var/lib/jenkins/plugins/目录下 执行命令 systemctl restart jenkins 重启jenkins服务
1、jenkins 启动关闭命令脚本 service jenkins stop service jenkins start
jenkins2.328配置连接harbor2.4的认证-jenkinsfile连接harbor—详细文档