Jenkins构建脚本中启动tomcat关键
一、启动tomcat
来源:
http://blog.csdn.net/prisonbreak_/article/details/50749576(给出方法)
http://veryyoung.me/blog/2016/04/19/jenkins-backgroud-process.html(给出方法+解释原因)
在网上查了资料,需要在执行脚本之前加入:export BUILD_ID=XXXXXX
XXXXX可以随便写的什么
具体原因还不知道,以后研究了,再来补充。
这里我就来补充一下咯(又是我copy的):
今天在配置 Jenkins Job 的时候,after mvn package 用命令行 nohup java -jar project-1.0-SNAPSHOT.jar > server.log 2>&1 & 起一个 spring-boot 项目,死活不生效。
ssh 到服务器上查不到对应的进程,而直接在服务器上执行是完全 OK 的。
Google 一番后得知,这是 Jenkins 的特性。
To reliably kill processes spawned by a job during a build, Jenkins 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.ProcessTree.disable” to the value “true”. This can be done as a parameter to the “java” binary when starting Jenkins:
`java -Dhudson.util.ProcessTree.disable=true -jar jenkins.war`
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.
具体链接请点击 ProcessTreeKiller。
大概意思是 Jenkins 是在启动 Job 的时候会给子进程设置环境变量,在结束 Job 的时候会检查进程的环境变量,如果包含 Jenkins 生成的,kill 掉。
解决方案:
启动 Jenkins 的时候加上 -Dhudson.util.ProcessTree.disable=true,也就是 java -Dhudson.util.ProcessTree.disable=true -jar jenkins.war
在后台进程前加上 BUILD_ID=dontKillMe, 也就是 BUILD_ID=dontKillMe nohup java -jar project-1.0-SNAPSHOT.jar > server.log 2>&1 &
二、maven构建的时候忽略Javadoc
maven构建的时候,忽略Javadoc可以加快速度
mvn clean package -D maven.javadoc.skip=true
Jenkins构建脚本中启动tomcat关键的更多相关文章
- 为什么eclipse中启动tomcat后,浏览器中出现404?
问题描述: tomcat压缩包加压后,启动lib文件夹下面的startup.bat,在浏览器中输入http://localhost:8080/后出现熟悉的界面. 但是在eclipse中,jsp可以正常 ...
- eclipse中启动tomcat,localhost:8080无法访问
问题 eclipse中启动tomcat,项目可以正常运行,但是localhost:8080无法访问. 关闭eclipse中的Tomact,直接从tomcat/bin 下的startup.bat启动,l ...
- 在eclipse中启动Tomcat报端口被占用的错误
安装配置好Tomcat之后,在浏览器中输入localhost,能正取打开页面.然后在eclipse中建立项目,创建Servlet之后,启动Tomcat,报端口被占用的错误.如图: 原因:原来已经启动了 ...
- Myeclipse中启动tomcat 异常
信息: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate ...
- centos7中启动tomcat提示bash: tomcat8.0.39/bin/startup.sh: 权限不够
问题描述: centos7中启动tomcat提示bash: tomcat8.0.39/bin/startup.sh: 权限不够 解决方案:先进入bin目录 [root@localhost/]# cd ...
- eclipse中启动tomcat后, 无法访问localhost:8080
问题: 今天老师讲了Servlet路径问题, 做了个测试在eclipse中启动tomcat后,在浏览器地址栏输入 http://localhost8080无法访问, 提示404错误, 正常情况是可以访 ...
- jenkin构建项目执行脚本后,脚本中启动的进程也随之关闭的解决办法
问题描述: 之前用jenkins构建项目(maven项目)后都是通过ssh先将war文件推送到远程服务器,然后执行远程的脚本(更新项目,重启tomcat),一直没有出现问题,今天使用jenkins构建 ...
- 约定Jenkins构建脚本
对于Jenkins的使用,我感觉只用到其中一小部分功能,但也就是这一小部分功能,也推动了整个CI/CD的过程,Jenkins的使用方式有很多中,可能我用到的只是其中一种,但是已经满足我的需求,便不再贪 ...
- 在eclipse中启动tomcat加载不了项目的解决方法
一.在server视图右键选择Add and Remove时,如果想要部署的项目不在左侧的待选列表中,或是弹出警告There are no resources that can be added or ...
随机推荐
- (转)MoMo的Unity3D研究院之Assetbundle的原理(六十一)
http://www.xuanyusong.com/archives/2373 Assetbundle 是Unity Pro提供提供的功能,它可以把多个游戏对象或者资源二进制文件封装到Assetbun ...
- C# 使用 System.Web.Script.Serialization 解析 JSON
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.易于人阅读和编写.同时也易于机器解析和生成.它基于JavaScript Programming Langu ...
- java_hibernate
入门:http://jingyan.baidu.com/article/cbf0e500965a352eab289368.html 步骤1.查看是否hibernate支持:file-->plug ...
- 起步X5 UI模型使用的新的JAVASCRIPT UI库 DHTMLX (简称DHX)
最近学习新版本的起步X5,发现 UI控件有很多变化,按培训师的解释,X5平台界面设计引入了新的JAVASCRIPT UI库 DHTMLX. 参考:DHX http://www.dhtmlx.com ...
- VirtualBox如何增加CentOS根目录容量
1.扩充磁盘容量 单位为M,40000为40G VBoxManage modifyhd centos.vdi --resize 40000 2.指定新的磁盘文件 系统 > 右击 > 设置 ...
- 客户端连接Redis
首先下载Jedis http://mvnrepository.com/artifact/redis.clients/jedis 然后脚本如下: package redistest; import ja ...
- redis深入研究
Redis 设计思路学习与总结 https://cloud.tencent.com/developer/article/1004464 Redis 设计思路学习与总结 下半年利用空余时间研究和分析了部 ...
- fedora25 采用二进制包安装mysql5.5.49
#添加用户和组 groupadd mysql useradd -s /sbin/nologin -g mysql -M mysql /etc/passwd id mysql #安装依赖包 [root@ ...
- centos和ubuntu下pycharm无法输入中文的解决办法
编辑启动的脚本文件 vim /usr/bin/pycharm ubuntu下添加 export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export ...
- mycat读写分离与主从切换
1, 分库分表的优缺点.以及为什么分表方式无法成为主流? 分表:在台server上,长处是易维护,相似表分区.缺点是在一台dbserver上.无法分担IO.负载集中. 分库:在多台server上,长处 ...