如何从Jenkins启动我的应用程序?

时间:2015-08-04 01:49:44

标签: java jenkins

我有一个Jenkins工作,它提取Java应用程序,编译.class文件中的Java文件,然后从类文件和所有依赖项中构建一个uberjar。然后我将此作为最终构建步骤:

/etc/init.d/vivian restart

重启功能调用“停止”然后“启动”:

WORK_DIR="/home/jenkins/vivian"
NAME="venus"
JAR="venus.jar"
USER="jenkins"
DAEMON="/usr/bin/java"
DAEMON_ARGS=" -cp /home/jenkins/vivian/venus.jar com.melonapp.venus.Main"

start () {
  if [ ! -f $WORK_DIR/venus.pid ]; then
      /usr/bin/java -cp /home/jenkins/vivian/venus.jar com.melonapp.venus.Main 
  fi
}

stop () {
    echo "Stopping venus..."
    /sbin/start-stop-daemon --stop --exec $DAEMON --pidfile $WORK_DIR/venus.pid
    rm $WORK_DIR/venus.pid
}

但是,我似乎遇到了这个问题:

https://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build

On Unix, you can use a wrapper like this to make the daemon behave. You can call your command like this:

daemonize -E BUILD_ID=dontKillMe /path/to/your/command

Note that this will set the BUILD_ID environment variable for the process being spawned to something other than the current BUILD_ID. Or you can start jenkins with -Dhudson.util.ProcessTree.disable=true - see ProcessTreeKiller for details.

但是“daemonize -E BUILD_ID = dontKillMe”只是给了我一个错误,而“-Dhudson.util.ProcessTree.disable = true”似乎没有效果?我把它添加到这个文件中:

/etc/default/jenkins

我添加的地方:

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT --httpListenAddress=127.0.0.1 Dhudson.util.ProcessTree.disable=true "

这个文件应该有效吗?

如何从Jenkins启动我的应用程序?

1 个答案:

答案 0 :(得分:0)

/ etc / default / jenkins文件中有拼写错误。在Dhudson.util.ProcessTree.disable=true之前缺少连字符“ - ”。它应该是 -Dhudson.util.ProcessTree.disable=true。 另外,daemonize -E BUILD_ID=dontKillMe的错误是什么?