`
liyinyin0504
  • 浏览: 9526 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

Jenkins

 
阅读更多
Pre steps:
Execute shell to download code from git, for example (QA):
git clone -b QA url
build tool maven:
Maven  version: Maven 2.2.1
Root POM: ./project/pom.xml
Goals and options: clean test package -P qa
Post Steps:
Del old folder and rename the target war:
Execute shell:
Delete old folders(maybe contains other team's file)
          rm -rf  data/apache-tomcat/webapps/ && mkdir -p data/apache-tomcat/webapps/
rename the package the war file and path
           mv ./project/*.war data/apache-tomcat/webapps/ROOT.war
shut down running process and restart, write these into post-install.sh:
cat>./post-install.sh<<EOF
#!/bin/sh
. /etc/profile

cd /data/apache-tomcat/bin;
./shutdown.sh -force
if ps -ef|grep -v grep | grep java | grep apache-tomcat;then
ps -ef|grep apache-tomcat|grep -v grep |awk '{print \$2}'|xargs kill -9 && echo "kill-9 killed"
fi
sleep 2;
cd /data/apache-tomcat/ && rm -rf webapps/ROOT temp/* work/*
rm -rf /data/apache-tomcat/logs/*
cd /data/apache-tomcat/bin && ./startup.sh &
#su tomcat ./startup.sh &
sleep 2;
ps -ef| grep java
EOF
Generate auto install file using install.sh
rm -rf *.rpm
/usr/local/bin/fpm -s dir -t rpm -n "name" -v 1.0.0.$BUILD_NUMBER --post-install ./post-install.sh  data
#dataservice_TP-1.0.0.$BUILD_NUMBER-1.x86_64.rpm
#find ./ -type f  -name "data*.rpm"  -ctime +90 -exec rm -f  {} \;
Email notification under post-build Actions
Add the target email list into project recipient list and project reply-to list, separate with space:

Call artifacts by ssh to install and start the application
Transfer the rpm file from dpjenkins server to target server, then execute rpm file to deploy the latest application
sudo rpm -ivh --force name-1.0.0.$BUILD_NUMBER-1.x86_64.rpm;
find ./ -type f  -name "name*.rpm"  -ctime +30 -exec rm -f  {} \;
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics