构建信息
Console Output Started by user jenkins [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/lib/jenkins/workspace/testTapd-ldap [Pipeline] { [Pipeline] stage [Pipeline] { (git pull) [Pipeline] checkout The recommended git tool is: NONE > git --version # timeout=10 > git --version # 'git version 1.8.3.1' using GIT_ASKPASS to set credentials gongfeng-auth-git > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 > git config core.sparsecheckout # timeout=10 Commit message: "add test code" > git rev-list --no-walk 565f3afa6bdb0c0dbf47d41f1f21233b3ae9dba2 # timeout=10 [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (build) [Pipeline] sh + mvn clean package -Dmaven.test.skip=true [INFO] Scanning for projects... [INFO] [INFO] ------------------------< com.joosure:TapdLdap >------------------------ [INFO] Building TapdLdap 0.0.21 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ TapdLdap --- [INFO] Deleting /var/lib/jenkins/workspace/testTapd-ldap/target [INFO] [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ TapdLdap --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to copy filtered properties files. [INFO] Copying 1 resource [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ TapdLdap --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 23 source files to /var/lib/jenkins/workspace/testTapd-ldap/target/classes [INFO] /var/lib/jenkins/workspace/testTapd-ldap/src/main/java/com/joosure/tapdldap/utils/JsonUtil.java: /var/lib/jenkins/workspace/testTapd-ldap/src/main/java/com/joosure/tapdldap/utils/JsonUtil.java uses unchecked or unsafe operations. [INFO] /var/lib/jenkins/workspace/testTapd-ldap/src/main/java/com/joosure/tapdldap/utils/JsonUtil.java: Recompile with -Xlint:unchecked for details. [INFO] [INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ TapdLdap --- [INFO] Not copying test resources [INFO] [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ TapdLdap --- [INFO] Not compiling test sources [INFO] [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ TapdLdap --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ TapdLdap --- [INFO] Building jar: /var/lib/jenkins/workspace/testTapd-ldap/target/TapdLdap-0.0.21.jar [INFO] [INFO] --- spring-boot-maven-plugin:2.6.1:repackage (repackage) @ TapdLdap --- [INFO] Replacing main artifact with repackaged archive [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.719 s [INFO] Finished at: 2021-12-28T00:41:37+08:00 [INFO] ------------------------------------------------------------------------ [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (cp jar) [Pipeline] sh + cp -f /var/lib/jenkins/workspace/testTapd-ldap/target/TapdLdap-0.0.21.jar /scripts/TapdLdap-0.0.21.jar [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (deploy) [Pipeline] sh + sh /scripts/testTapdldap_start.sh [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS
但看构建日志信息构建是成功的,但是进入到服务器ps查询java进程,该项目并没有启动。查看启动日志文件只有一行:/usr/local/bin/java: No such file or directory
原因:jenkins构建pipeline流水线退出时,会清理自己执行的每个shell命令
解决方案:在脚本中添加export JENKINS_NODE_cookie=dontKillMe和export BUILD_ID=dontKillMe变量
shell启动脚本
#!/bin/bash workdir=$(cd `dirname $0`; pwd) cd $workdir jarname=`ls TapdLdap-*.jar|head -n1` #chmod +x $jarname current_date=`date +%Y%m%d%H%M%S` export JENKINS_NODE_cookie=dontKillMe #添加此环境变量 export BUILD_ID=dontKillMe #添加此环境变量 geshu=`ps -ef|grep "$jarname"|grep -v "grep"|wc -l` case $1 in start) #geshu=`ps -ef|grep "main-*.jar"|grep -v "grep"|wc -l` if [ $geshu == 1 ];then echo "program is ruuning" else nohup java -jar $jarname >> TapdLdap.log 2>&1 & #--spring.profiles.active=prod >> TapdLdap.log 2>&1 & fi ;; stop) if [ $geshu == 1 ];then ps -ef|grep "$jarname" |grep -v grep |awk '{print $2}' | xargs kill -9 else echo "program is stop" fi ;; restart) if [ $geshu == 1 ];then ps -ef|grep "$jarname" |grep -v grep |awk '{print $2}' | xargs kill -9 mv $jarname $jarname-$current_date cp -f /var/lib/jenkins/workspace/testTapd-ldap/target/TapdLdap-0.0.21.jar /scripts/TapdLdap-0.0.21.jar nohup java -jar $jarname >> TapdLdap.log 2>&1 & #--spring.profiles.active=prod >> TapdLdap.log 2>&1 & else echo "program is stop" fi ;; *) echo "Usage:[start|stop|restart]" esac
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)