Jenkins CICD Code Build release Process

Source: Internet
Author: User

First, the release environment

Publish Script

#!/bin/bash#nodegroup1= "172.16.8.11 172.16.8.12" group2= "172.16.8.13 172.16.8.14" #deloytomcat1_dir =/app/ tomcat1tomcat2_dir=/app/tomcat2tomcat3_dir=/app/tomcat3tomcat4_dir=/app/tomcat4#backupbackup_dir1=/app/ backup1backup_dir2=/app/backup2backup_dir3=/app/backup3backup_dir4=/app/backup4tmp_dir1=/app/deploy1tmp_dir2=/ app/deploy2tmp_dir3=/app/deploy3tmp_dir4=/app/deploy4ctime=$ (date + "%h-%m-%s") date=$ (date "+%y-%m-%d") SHELL_NAME = "deploy.sh" shell_log= "/app/${shell_name}.log" date_n= "$ (DATE + '%y%m%d%h%m%s ')" user_n= ' WhoAmI ' echo "${date_n} ${ User_n} execute $ [INFO] [email protected] ">>${shell_log}writelog () {loginfo=$1 echo" ${cdate} ${ctim  E}: ${sehll_name}: ${loginfo} ">> ${shell_log}}ghsmp_deploy_group1 () {#echo" ${date_n} ${user_n} execute $ [INFO] [email protected] ">>${shell_log} deploy=$1 tomcat_dir=$2 if [$DEPLOY =" deploy1 "]; Then Scp-r [email protected]:/app/$DEPLOY/* $TMP _dir1 for node in $grouP1;do if [$tomcat _dir = "$tomcat 1_dir"];then ssh $node "/app/tomcat1/bin/shutdown.sh"                  SSH $node mkdir $backup _dir1/$DATE ssh $node mv $tomcat _dir/webapps/* $backup _dir1/$DATE                  SSH $node rm-rf $tomcat _dir/webapps/* scp-r ${tmp_dir1}/* $node: $tomcat _dir/webapps SSH $node unzip $tomcat _dir/webapps/*.zip-d $tomcat _dir/webapps/ssh $node cp-rf $tomcat _dir/webapps/config/* $tomcat _dir/webapps/root/web-inf/classes/ssh $node rm-rf $tomcat _dir/webapps/*.zi P SSH $node "/app/tomcat1/bin/startup.sh" Else Echo "${node} Tomcaxxxdeploy F               ailed! "                           Cat tomcat4_deploy_failed? Fi done elif [$DEPLOY = "Deploy2"]; Then Scp-r [email protected]:/app/$DEPLOY/* $TMP _DIR2 for node in $group 1;do if [$tomcat _dir = "$Tomcat2_dir "];then ssh $node"/app/tomcat2/bin/shutdown.sh "ssh $node mkdir $backup _di r2/$DATE ssh $node mv $tomcat _dir/webapps/* $backup _dir2/$DATE ssh $node rm-rf $tomcat _dir/webapps/* scp-r ${tmp_dir2}/* $node: $tomcat _dir/webapps ssh $node unzip $tomcat _di r/webapps/*.zip-d $tomcat _dir/webapps/ssh $node cp-rf $tomcat _dir/webapps/config/* $tomcat _dir/webapps /root/web-inf/classes/ssh $node rm-rf $tomcat _dir/webapps/*.zip ssh $node "/APP/TOMCA                t2/bin/startup.sh "Else echo" ${node} TOMCAT2 DEPLOY failed! "              Cat tomcat4_deploy_failed? Fi done elif [$DEPLOY = "Deploy3"]; Then Scp-r [email protected]:/app/$DEPLOY/* $TMP _dir3 for node in $group 1;do if [$tomcat _dir = "$tomcat 3_dir"];then ssh $node "/app/tomcat3/bin/shutdown.sh "ssh $node mkdir $backup _dir3/$DATE ssh $node mv $tomcat _dir/we bapps/* $backup _dir3/$DATE ssh $node rm-rf $tomcat _dir/webapps/* scp-r ${tmp_dir3}/*                  $node: $tomcat _dir/webapps ssh $node unzip $tomcat _dir/webapps/*.zip-d $tomcat _dir/webapps/ SSH $node cp-rf $tomcat _dir/webapps/config/* $tomcat _dir/webapps/root/web-inf/classes/ssh $node RM                 -RF $tomcat _dir/webapps/*.zip ssh $node "/app/tomcat3/bin/startup.sh" Else               echo "${node} TOMCAT3 DEPLOY failed!"              Cat tomcat4_deploy_failed? Fi done elif [$DEPLOY = "Deploy4"]; Then Scp-r [email protected]:/app/$DEPLOY/* $TMP _DIR4 for node in $group 1;do if [$to Mcat_dir = "$tomcat 4_dir"];then ssh $node "/app/tomcat4/bin/shutdown.sh" ssh $nodemkdir $backup _dir4/$DATE ssh $node mv $tomcat _dir/webapps/* $backup _dir4/$DATE ssh $node RM-RF $tomcat _dir/webapps/* scp-r ${tmp_dir4}/* $node: $tomcat _dir/webapps ssh $node Unzip $tomcat _dir/webapps/*.zip-d $tomcat _dir/webapps/ssh $node cp-rf $tomcat _dir/webapps/config/* $to Mcat_dir/webapps/root/web-inf/classes/ssh $node rm-rf $tomcat _dir/webapps/*.zip ssh $n        Ode "/app/tomcat4/bin/startup.sh" Else Echo "${node} tomcaxxxdeploy failed!"              Cat tomcat4_deploy_failed? Fi done Else echo "DEPLOY ERROR" fi}ghsmp_deploy_group2 () {deploy=$1 tomcat_dir= $ if [$DEPLOY = "deploy1"]; Then Scp-r [email protected]:/app/$DEPLOY/* $TMP _dir1 for node in $group 2;do if [$tom Cat_dir = "$tomcat 1_dir"];then ssh $node "/app/tomcat1/bin/shutdown.sh "ssh $node mkdir $backup _dir1/$DATE ssh $node mv $tomcat _dir/webapps/* $b ackup_dir1/$DATE ssh $node rm-rf $tomcat _dir/webapps/* scp-r ${tmp_dir1}/* $node: $tom Cat_dir/webapps ssh $node unzip $tomcat _dir/webapps/*.zip-d $tomcat _dir/webapps/ssh $n Ode cp-rf $tomcat _dir/webapps/config/* $tomcat _dir/webapps/root/web-inf/classes/ssh $node rm-rf $TOMCA T_dir/webapps/*.zip ssh $node "/app/tomcat1/bin/startup.sh" Else echo "Tomcaxx           Xdeploy ERROR? "             Cat tomcat4_deploy_failed? Fi done elif [$DEPLOY = "Deploy2"]; Then Scp-r [email protected]:/app/$DEPLOY/* $TMP _DIR2 for node in $group 2;do if [$tomcat _dir = "$tomcat 2_dir"];then ssh $node "/app/tomcat2/bin/shutdown.sh" ssh $nod e mkdir $backup _dir2/$DATE                 SSH $node mv $tomcat _dir/webapps/* $backup _dir2/$DATE ssh $node rm-rf $tomcat _dir/weba pps/* scp-r ${tmp_dir2}/* $node: $tomcat _dir/webapps ssh $node unzip $tomcat _dir/webapps /*.zip-d $tomcat _dir/webapps/ssh $node cp-rf $tomcat _dir/webapps/config/* $tomcat _dir/webapps/root/web -inf/classes/ssh $node rm-rf $tomcat _dir/webapps/*.zip ssh $node "/app/tomcat2/bin/st        artup.sh "Else echo" TOMCAT2 DEPLOY ERROR? "              Cat tomcat4_deploy_failed? Fi done elif [$DEPLOY = "Deploy3"]; Then Scp-r [email protected]:/app/$DEPLOY/* $TMP _dir3 for node in $group 2;do if [$tomcat _dir = "$tomcat 3_dir"];then ssh $node "/app/tomcat3/bin/shutdown.sh" ssh $nod e mkdir $backup _dir3/$DATE ssh $node mv $tomcat _dir/webapps/* $backup _dir3/$DATE                  SSH $node rm-rf $tomcat _dir/webapps/* scp-r ${tmp_dir3}/* $node: $tomcat _dir/webapps SSH $node unzip $tomcat _dir/webapps/*.zip-d $tomcat _dir/webapps/ssh $node cp-rf $TOMC at_dir/webapps/config/* $tomcat _dir/webapps/root/web-inf/classes/ssh $node rm-rf $tomcat _dir/webapps/*.            Zip ssh $node "/app/tomcat3/bin/startup.sh" Else echo "TOMCAT3 DEPLOY ERROR?"              Cat tomcat4_deploy_failed? Fi done elif [$DEPLOY = "Deploy4"]; Then Scp-r [email protected]:/app/$DEPLOY/* $TMP _DIR4 for node in $group 2;do if [$to Mcat_dir = "$tomcat 4_dir"];then ssh $node "/app/tomcat4/bin/shutdown.sh" ssh $node MKD  IR $backup _dir4/$DATE ssh $node mv $tomcat _dir/webapps/* $backup _dir4/$DATE ssh $node RM           -RF $tomcat _dir/webapps/*       Scp-r ${tmp_dir4}/* $node: $tomcat _dir/webapps ssh $node unzip $tomcat _dir/webapps/*.zip-d $TOMCA                  T_dir/webapps/ssh $node "Cp-rf $tomcat _dir/webapps/config/* $tomcat _dir/webapps/root/web-inf/classes/"                  SSH $node rm-rf $tomcat _dir/webapps/*.zip ssh $node "/app/tomcat4/bin/startup.sh"              echo "${node} deploy Success!"                 else echo "${node} TOMCAT4 DEPLOY error!"               Cat tomcat4_deploy_failed?         Fi do else echo "DEPLOY ERROR" Fi}rollback_fun () {for node in $ROLLBACK _list;do SSH $node "rm-f/webroot/web-demo && ln-s/opt/webroot/$1/webroot/web-demo" echo "${node} rollback s        Uccess! "                 Done}main () {case $ in Deploy_group1) Ghsmp_deploy_group1 $ $;                 ;;              DEPLOY_GROUP2) ghsmp_deploy_group2;           ;; *) echo $ "Usage: $ deploy_group1|deploy_group2|ghsmp_rollback}" Esac}main

Jenkins CICD Code build publishing process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.