jenkins配置使用
1,General
2,源码管理
3,构建触发器
4,构建环境
5,Pre Steps
6,Bulid
7,Post Steps
Post Steps 执行的命令:
#!/bin/bash
echo "execute shell start to cp project "
cd /usr/soft/vxsoft/target
cp ./*.war /usr/soft/tomcat/webapps
echo "execute shell cp end "
BUILD_ID=dontKillMe nohup /usr/soft/shell/restart.sh &
echo "execute starting "
shell 目录下的 restart 启动的脚本:
应赋予shell目录权限
#!/bin/sh
tomcat_dirname=`cd /usr/soft/tomcat ; pwd`
pid=`ps -ef| grep ${tomcat_dirname}| grep -v "grep"| awk '{print $2}'`
if [ -n "${pid}" ];then
echo "Will shutdown Tomcat: ${pid}"
kill -9 ${pid}
sleep 2
sh ${tomcat_dirname}/bin/startup.sh
new_pid=`ps -ef| grep ${tomcat_dirname}| grep -v "grep"| awk '{print $2}'`
if [ -n "${new_pid}" ];then
echo "Tomcat has been started.The new pid is ${new_pid}!"
sleep 2
#tail -f ${tomcat_dirname}/logs/catalina.out
else
echo "Tomcat did not start!"
fi
else
echo "No Tomcat process! Start in 3 seconds"
sleep 3
sh ${tomcat_dirname}/bin/startup.sh
#tail -f ${tomcat_dirname}/logs/catalina.out
fi
---------完-----------
以下为部署jar启动方式:
start.sh
#!/bin/bash
echo "-------starting------"
cd /usr/soft/web/target
chmod 777 wx-server.jar
java -jar wx-server.jar &
停止脚本:stop.sh
#!/bin/bash
echo "------stoping server-----"
pid=`ps -ef | grep wx-server.jar | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ];then
echo "kill -9 pid:"$pid
kill -9 $pid
fi