jenkins 自动化部署

时间:2022-05-01 18:18:15

Execute shell Command

BUILD_ID=DONTKILLME
if [ ! -d "/usr/jenkins/$JOB_NAME" ]; then
mkdir /usr/jenkins/$JOB_NAME
fi
cd /usr/jenkins/$JOB_NAME
rm -rf *
cp $JENKINS_HOME/workspace/$JOB_NAME/target/*.zip ./
unzip -o *.zip
cd /usr/zocrm/server/tomcat8/zocrm/bin

PROJECT=/usr/zocrm/server/tomcat8/zocrm/
echo "--------------shutdown tomcat server-------------"

count=`ps -ef|grep -v 'grep'|grep $PROJECT |awk '{print $2}'|wc -l`
if [ $count -gt 0 ];then
echo "kill running process, please waiting..."
kill -9 `ps -ef|grep -v 'grep'|grep $PROJECT|awk '{print $2}'`
sleep 1
else
echo "--------------shutdown tomcat done -------------"
fi

rm -rf /usr/zocrm/projects/zocrm/WEB-INF/classes/cn/aresoft
rm -rf /usr/zocrm/projects/zocrm/WEB-INF/lib
unzip -o /usr/jenkins/$JOB_NAME/*.war -d /usr/zocrm/projects/zocrm
export JAVA_PATH=/usr/bin
export JRE_HOME=/usr
./startup.sh

 

*********************************日志************************************************

Started by user dev
Building in workspace /root/.jenkins/workspace/zocrm-147
Updating https://172.10.10.101/svn/路径 at revision '2019-05-27T15:49:42.625 +0800'
Using sole credentials liaokai/****** in realm ‘<https://172.10.10.100:443> VisualSVN Server’
U
At revision 9695

Using sole credentials liaokai/****** in realm ‘<https://172.10.10.100:443> VisualSVN Server’
Parsing POMs
using global settings config with name MyGlobalSettings
Replacing all maven server entries not found in credentials list is true
Established TCP socket on 33518
[zocrm-147] $ /usr/jenkins/jdk1.8.0_152/bin/java -cp /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.12-alpha-1.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3/boot/plexus-classworlds-2.5.2.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3/conf/logging jenkins.maven3.agent.Maven35Main /root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3 /root/.jenkins/war/WEB-INF/lib/remoting-3.10.2.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.12-alpha-1.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 33518
<===[JENKINS REMOTING CAPACITY]===>channel started
using global settings config with name MyGlobalSettings
Replacing all maven server entries not found in credentials list is true
Executing Maven: -B -f /root/.jenkins/workspace/zocrm-147/pom.xml -gs /tmp/global-settings127350087469421300.xml clean package -Pdev
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building zocrm.manager 2.1.6
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ zocrm.manager ---
[INFO] Deleting /root/.jenkins/workspace/zocrm-147/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ zocrm.manager ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 860 resources
[INFO] Copying 14 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ zocrm.manager ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1488 source files to /root/.jenkins/workspace/zocrm-147/target/classes
[INFO] /root/.jenkins/workspace/zocrm-147/src/cn/aresoft/manager/push/UmengNotification.java: Some input files use or override a deprecated API.
[INFO] /root/.jenkins/workspace/zocrm-147/src/cn/aresoft/manager/push/UmengNotification.java: Recompile with -Xlint:deprecation for details.
[INFO] /root/.jenkins/workspace/zocrm-147/src/cn/aresoft/manager/service/impl/redis/RedisCacheStorageServiceImpl.java: Some input files use unchecked or unsafe operations.
[INFO] /root/.jenkins/workspace/zocrm-147/src/cn/aresoft/manager/service/impl/redis/RedisCacheStorageServiceImpl.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- aspectj-maven-plugin:1.7:compile (default) @ zocrm.manager ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ zocrm.manager ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/zocrm-147/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ zocrm.manager ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ zocrm.manager ---
[INFO] No tests to run.
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-war-plugin:2.6:war (default-war) @ zocrm.manager ---
[INFO] Packaging webapp
[INFO] Assembling webapp [zocrm.manager] in [/root/.jenkins/workspace/zocrm-147/target/zocrm.manager-2.1.6]
[INFO] Processing war project
[INFO] Copying webapp resources [/root/.jenkins/workspace/zocrm-147/webapp]
[INFO] Webapp assembled in [1695 msecs]
[INFO] Building war: /root/.jenkins/workspace/zocrm-147/target/zocrm.manager-2.1.6.war
[INFO]
[INFO] --- maven-assembly-plugin:2.4:single (makezip) @ zocrm.manager ---
[INFO] Reading assembly descriptor: assembly.xml
[INFO] Building zip: /root/.jenkins/workspace/zocrm-147/target/zocrm2.1.6.zip
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.512 s
[INFO] Finished at: 2019-05-27T15:50:38+08:00
[INFO] Final Memory: 37M/433M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /root/.jenkins/workspace/zocrm-147/pom.xml to zocrm.manager/zocrm.manager/2.1.6/zocrm.manager-2.1.6.pom
[JENKINS] Archiving /root/.jenkins/workspace/zocrm-147/target/zocrm.manager-2.1.6.war to zocrm.manager/zocrm.manager/2.1.6/zocrm.manager-2.1.6.war
[JENKINS] Archiving /root/.jenkins/workspace/zocrm-147/target/zocrm2.1.6.zip to zocrm.manager/zocrm.manager/2.1.6/zocrm.manager-2.1.6.zip
channel stopped
[zocrm-147] $ /bin/sh -xe /tmp/jenkins1993294478867023234.sh
+ BUILD_ID=DONTKILLME
+ '[' '!' -d /usr/jenkins/zocrm-147 ']'
+ cd /usr/jenkins/zocrm-147
+ rm -rf zocrm2.1.6.zip zocrm.manager-2.1.6.war
+ cp /root/.jenkins/workspace/zocrm-147/target/zocrm2.1.6.zip ./
+ unzip -o zocrm2.1.6.zip
Archive: zocrm2.1.6.zip
extracting: zocrm.manager-2.1.6.war
+ cd /usr/zocrm/server/tomcat8/zocrm/bin
+ PROJECT=/usr/zocrm/server/tomcat8/zocrm/
+ echo '--------------shutdown tomcat server-------------'
--------------shutdown tomcat server-------------
++ ps -ef
++ grep -v grep
++ grep /usr/zocrm/server/tomcat8/zocrm/
++ awk '{print $2}'
++ wc -l
+ count=3
+ '[' 3 -gt 0 ']'
+ echo 'kill running process, please waiting...'
kill running process, please waiting...
++ ps -ef
++ grep -v grep
++ grep /usr/zocrm/server/tomcat8/zocrm/
++ awk '{print $2}'
+ kill -9 4388 4389 4390
+ sleep 1
+ rm -rf /usr/zocrm/projects/zocrm/WEB-INF/classes/cn/aresoft
+ rm -rf /usr/zocrm/projects/zocrm/WEB-INF/lib
+ unzip -o /usr/jenkins/zocrm-147/zocrm.manager-2.1.6.war -d /usr/zocrm/projects/zocrm
Archive: /usr/jenkins/zocrm-147/zocrm.manager-2.1.6.war
inflating: ...........正文。。。。。。
+ export JAVA_PATH=/usr/bin
+ JAVA_PATH=/usr/bin
+ export JRE_HOME=/usr
+ JRE_HOME=/usr
+ ./startup.sh
Tomcat started.
Process leaked file descriptors. See https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors for more information
Finished: SUCCESS