一、启动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关键的更多相关文章

  1. 为什么eclipse中启动tomcat后,浏览器中出现404?

    问题描述: tomcat压缩包加压后,启动lib文件夹下面的startup.bat,在浏览器中输入http://localhost:8080/后出现熟悉的界面. 但是在eclipse中,jsp可以正常 ...

  2. eclipse中启动tomcat,localhost:8080无法访问

    问题 eclipse中启动tomcat,项目可以正常运行,但是localhost:8080无法访问. 关闭eclipse中的Tomact,直接从tomcat/bin 下的startup.bat启动,l ...

  3. 在eclipse中启动Tomcat报端口被占用的错误

    安装配置好Tomcat之后,在浏览器中输入localhost,能正取打开页面.然后在eclipse中建立项目,创建Servlet之后,启动Tomcat,报端口被占用的错误.如图: 原因:原来已经启动了 ...

  4. Myeclipse中启动tomcat 异常

    信息: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate ...

  5. centos7中启动tomcat提示bash: tomcat8.0.39/bin/startup.sh: 权限不够

    问题描述: centos7中启动tomcat提示bash: tomcat8.0.39/bin/startup.sh: 权限不够 解决方案:先进入bin目录 [root@localhost/]# cd ...

  6. eclipse中启动tomcat后, 无法访问localhost:8080

    问题: 今天老师讲了Servlet路径问题, 做了个测试在eclipse中启动tomcat后,在浏览器地址栏输入 http://localhost8080无法访问, 提示404错误, 正常情况是可以访 ...

  7. jenkin构建项目执行脚本后,脚本中启动的进程也随之关闭的解决办法

    问题描述: 之前用jenkins构建项目(maven项目)后都是通过ssh先将war文件推送到远程服务器,然后执行远程的脚本(更新项目,重启tomcat),一直没有出现问题,今天使用jenkins构建 ...

  8. 约定Jenkins构建脚本

    对于Jenkins的使用,我感觉只用到其中一小部分功能,但也就是这一小部分功能,也推动了整个CI/CD的过程,Jenkins的使用方式有很多中,可能我用到的只是其中一种,但是已经满足我的需求,便不再贪 ...

  9. 在eclipse中启动tomcat加载不了项目的解决方法

    一.在server视图右键选择Add and Remove时,如果想要部署的项目不在左侧的待选列表中,或是弹出警告There are no resources that can be added or ...

随机推荐

  1. SQLSERVER中汉字提取首字母的拼音函数的实现

    --创建一个汉字提取首字母的函数--还存在一点小小的问题(符号?)create function hs(@a varchar(1000)='')returns varchar(1000)asbegin ...

  2. vs 代理登入

    https://msdn.microsoft.com/zh-cn/vstudio/dn771556.aspx

  3. coco2dx jni 调用 java 相机返回 图片数据

    新建 一个项目 名字:testJin  包名:com.TanSon.org  python命令:python create_project.py -project testJin -package c ...

  4. 一起來玩鳥 Starling Framework(9)Particle

    最後,來看看Starling裡一個很炫的功能:Particle.Particle屬於extension,所以要另外下載檔案:Starling-Extension-Particle-System.下載之 ...

  5. prometheus的坑

    prometheus是一个用于监控k8s集群状态的工具.今天在主机上配置这个东西,遇到了一个坑,调查了一段时间才解决,记之. 首先,根据网上的教程,利用helm安装这个东西很方便,只要三条指令(ref ...

  6. windows下curl报错:curl : (1) Protocol https not supported or disabled in libcurl

    如果命令语句中有单引号,改为英文双引号试一下

  7. 2017.11.21 postgre更新时需要联合其他表的信息

    现在需要更新t_user表,但是前台传来的参数 tenant_name 并不在这个表中,需要联合另一个表t_tenant. 要注意的一点是:set后面的字段不要写成 u.fd_validity,否则会 ...

  8. 读取Properties配置文件, 四种方式都可以得到webroot/WEB-INF/classes这个路径

    下面四种方式都可以得到webroot/WEB-INF/classes这个路径,有什么区别,哪种方式最好? String path = this.getClass().getResource(" ...

  9. attempt to dereference a generic a pointer(转)

    在Linux下的GDB环境中,用p   命令查看一个void   *型的变量的时候,提示为:  "attempt   to   dereference   a   generic   a   ...

  10. Visual studio C++ MFC之点击按钮(菜单栏)生成新窗口

    背景 当前做的APP有菜单栏,菜单栏有一项需要对下位机相关参数进行设置,则必须弹出一个窗口来实现设置操作.本篇即对点击菜单栏生成新的窗口,在新的窗口内完成相应计划后结束新窗口并返回原窗口的方法进行简述 ...