jenkins发版svn

1、在mac上直接安装Jenkins,下载地址 :

2、安装插件:系统管理--》插件管理

publish over ssh

jenkins发版svn

jenkins发版svn

Exec command:

cd /usr/local/apache-tomcat-7.0.81/bin/
sh jenkins.sh 8080 hc-adapter /usr/local/jdk1.7

这里与服务器上tomcat中的脚步发生互动了。

jenkins.sh 负责服务器上tomcat的关闭和启动;

具体代码:

#!/bin/bash
#Time
log_time=`date +[%Y-%m-%d]%H:%M:%S` ###manual_properties###
tomcat_port=$1
war_Dir=/opt/jenkins
war_Name=$2
debug_port=$3
###manual_properties### echo "********************************** ${log_time} *************************************"
echo "updating server environment start"
export JAVA_HOME=$3
export JRE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar/
sleep 3
echo "updating server environment end"
#build check funcation
echo "check tomcat status..."
check_tomcat_status(){
netstat -ant|grep ${tomcat_port} > /dev/null
t=$?
if [ $t -eq 0 ]; then
echo "tomcat is running....port is ${tomcat_port}"
echo "shutdown tomcat....."
echo ">>>>>>>shutdown tomcat begin<<<<<<<<"
sh shutdown.sh
echo ">>>>>>>shutdown tomcat end <<<<<<<<"
sleep 15
elif [ $t -ne 0 ];then
echo "tomcat is poweroff"
fi
} #check tomcat status invoke function
check_tomcat_status export TOMCAT_HOME=/usr/local/tomcat8
#echo "-------Input process name first"
## 从控制台读取要杀的进程名(read the value from the console)
#read input1
## 获取pid (get the pid)
#PID=$(ps x|grep $input1|grep -v grep|awk '{printf $1}')
PID=$(ps x|grep $TOMCAT_HOME|grep -v grep|awk '{printf $1}')
if [ $? -eq 0 ]; then
echo "---------process id(进程id):$PID"
echo "-------begin to kill the pid(开始杀进程)"
kill -9 $PID
if [ $? -eq 0 ];then
# echo "----------kill $input1 success(成功杀死进程)"
echo "----------kill $TOMCAT_HOME success(成功杀死进程)"
else
echo "----------kill $input1 fail(杀死进程失败,可能该进程不存在)"
fi
else
## 实际测试:进程不存在时不会走这个else(in fact,this situation will not happen)
echo "---------process $input1 not exit(该进程不存在)"
exit
fi
## 睡眠3秒,确保进程已停止(sleep 3s make sure the process has killed)
echo "-------wait for closing the tomcat(等待tomcat被关闭)"
sleep 3s echo "-------begain to start the tomcat service (开始启动tomcat服务)"
$TOMCAT_HOME/bin/startup.sh && tail -f $TOMCAT_HOME/logs/catalina.out #transfer application package
echo "-------------- begin transfer war package to tomcat webapps -------------------" if [ -z $war_Dir ];then
echo "Folder ${war_Dir} is empty.please check war package in this folder!"
exit 1
else
echo "Find ${war_Dir} exist war package ${war_Name}"
echo "deleteing old package ${war_Name} in tomcat"
rm -rf ../webapps/${war_Name}*
rm -rf ../work/
echo "start transfer ${war_Name} to tomcat"
mv ${war_Dir}/${war_Name}.war ../webapps/
sleep 10
fi
echo "-------------- transfer war package to tomcat webapps end -------------------"
echo " >>>>>>> rebooting tomcat begin <<<<<<<<"
sh startup.sh
echo " >>>>>>> rebooting tomcat end <<<<<<<<"
echo "the log you can read in canalina.out"
echo "************************ deploy war package into container Successlly **********************************"

  

上一篇:Coding编译连接过程中遇到的问题及解决方法(iOS)


下一篇:vue.config.js初始化配置