git pull source maven build deployment script details

  • 2020-05-15 03:28:41
  • OfStack

Deploy some middleware to the test machine script

Get the source from git, build maven, copy jar to the server, back up the old version, and restart.


#!/bin/bash

server_ips=(132.121.100.44 132.121.100.45 132.121.100.46 132.121.100.47)
    git_url=http://seaboat:123456@132.122.1.21:8888/splan/dbpool-src.git
    port=22
    user=seaboat
    dbproxy_base=/data/seaboat/dbproxy
    version=dbpool-service-1.2.2.jar
    currentTime=`date '+%Y%m%d%H%M%S'`
    dir=`pwd`

    function doGit(){
        echo "starting........"
            rm -rf ./dbpool-src
            git clone $git_url
            echo "git clone successed......."
    }

function mavenBuild(){
    echo "maven building.......... "
        set -e 
        cd dbpool-src/dbpool-service 
        mvn clean 
        mvn package -Dmaven.test.skip=true
        echo "maven builds successed.........."
}

function deployToServer(){
    echo "starting deploy to server"
        for ip in ${server_ips[@]};
    do
        scp -r $dir/dbpool-src/dbpool-service/target/$version $user@$ip:$dbproxy_base/lib/tmp/
            ssh -p $port $user@$ip "cd dbproxy/bin; ./deploy.sh $version $currentTime"
            done
    echo "deploy to servers successfully!"
}

doGit
mavenBuild
deployToServer

Deployment script deploy.sh for middleware


#!/bin/bash

. /etc/profile

cd
cd dbproxy/lib/tmp
cp -f $1 ../$1.$2
cp -f $1 ../$1

cd
cd dbproxy/bin
./shutdown.sh
./startup.sh

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: