【问题标题】:Using Jenkins pipeline, running a jar file in background using nohup does not launch the jar使用 Jenkins 管道,使用 nohup 在后台运行 jar 文件不会启动 jar
【发布时间】:2018-07-06 02:51:53
【问题描述】:

我在 MacOS-HighSierra 上使用带有管道的 Jenkins 版本 2.121.1。 我的项目依赖于登录服务器,这是一个 Springboot 工件,在本地运行,我想在构建之前启动它。我有一个 shell 脚本来启动登录服务器。 shell 脚本在命令行中运行良好。当我在 Jenkins 的上下文中运行相同的内容时,它失败了。下面是 runloginserver shell 脚本中的代码:

nohup java -jar /absolute/path/login-module/login-api.jar >/dev/null 2>&1 &

在我的 Jenkinsfile 中,我将阶段定义如下:

stage('Launch-login') {
  steps {
   script{
      withEnv(['JENKINS_NODE_COOKIE=dontkill']) {

        sh '/absolute/path/runloginserver '

       }           
   }
 }

}

控制台输出没有错误。没有生成 nohup.out。并且服务器还没有启动

【问题讨论】:

    标签: spring-boot jenkins jenkins-pipeline macos-high-sierra


    【解决方案1】:

    您可能遇到了Jenkins ProcessTree Killer。这是 Jenkins 的“功能”,它会在构建完成时终止构建期间启动的任何后台进程,即使该进程是使用 nohup 启动的或以其他方式与其父进程分离的。链接中有关于如何禁用此行为的说明 - 可以全局禁用,也可以仅针对特定进程禁用。

    【讨论】:

    • 不,我知道 ProcessTree Killer。如果您查看我共享的代码,我已经在处理它了。 JENKINS_NODE_COOKIE。问题是应用程序根本没有启动。没有错误,也没有日志。还有其他想法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-17
    • 1970-01-01
    • 2018-06-29
    • 2013-07-08
    相关资源
    最近更新 更多