使用Jenkins Pipeline自动化构建发布Java项目(3)

ssh $server "pkill -9 -f $tomcat"
ssh $server "rm -rf $tomcat/webapps/ROOT; mv $tomcat/webapps/ROOT.war $tomcat/webapps/ROOT.war.bak"
scp $project.war $server:$tomcat/webapps/ROOT.war
ssh $server "chown $tomcat/webapps/ROOT.war"
ssh $server "su - www -c $tomcat/bin/startup.sh"

sleep 5

3, 回滚脚本(跳板机)

#!/bin/bash
project="$1"

if [ $# -lt 1 ]; then
  echo "usage: $0 <project>"
  exit 1
fi

case "$project" in
        test_api)
        tomcat=/opt/tomcat_api
        server="test"
    ;;
        test_report)
        tomcat=/opt/tomcat_report
        server="test"
    ;;
        test_job)
        tomcat=/opt/tomcat_job
        server="test"
    ;;

esac

ssh $server "pkill -9 -f $tomcat"
ssh $server "rm -rf $tomcat/webapps/ROOT; mv $tomcat/webapps/ROOT.war.bak $tomcat/webapps/ROOT.war"
ssh $server "su - www -c $tomcat/bin/startup.sh"
sleep 5

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/b2ea847f16a1cb8fb88caaea2804f786.html