首页 > 代码库 > jenkins自动部署
jenkins自动部署
准备的东西
ip.txt
192.168.1.10
192.168.1.10
192.168.1.10
auto_deploy_war.sh
#!/bin/bash
#Auto deploy Tomcat for jenkins perf
#by author wugk 2016-07-06
export JAVA_HOME=/usr/java/jdk1.6.0_25
TOMCAT_PID=`/usr/sbin/lsof -n -P -t -i :8081`
TOMCAT_DIR="/usr/local/tomcat/"
FILES="jfedu.war"
DES_DIR="/export/data/tomcatRoot/ptest.jd.com/"
DES_URL="http://123.57.11.203:8080/job/Ptest_Online/lastSuccessfulBuild/target"
BAK_DIR="/export/backup/`date +%Y%m%d-%H%M`"
[ -n "$TOMCAT_PID" ] && kill -9 $TOMCAT_PID
cd $DES_DIR
rm -rf $FILES
mkdir -p $BAK_DIR;\cp -a $DES_DIR/* $BAK_DIR/
rm -rf $DES_DIR/*
wget $DES_URL/$FILES
/usr/java/jdk1.6.0_25/bin/jar -xvf $FILES
####################
cd $TOMCAT_DIR;rm -rf work
/bin/sh $TOMCAT_DIR/bin/start.sh
sleep 10
tail -n 50 $TOMCAT_DIR/logs/catalina.out
ssh+for循环
#!/bin/bash
for ip in ip.txt;do
ssh root@$ip ‘bash -x -s‘</data/sh/auto_deploy_war.sh;
done
ansible
jenkins自动部署