【Git】 自动化Maven项目构建脚本(二)

这次脚本增加了构建选择,可以按需构建了。

#!/bin/bash
#-----------------------------------------------
# FileName: auto-build.sh
# Reversion: 1.2
# Date: 2017/07/27
# Author: zhengwenqiang
# Email: zhengwenqiang@bonc.com.cn
# Description: build project eg "security portal cas " from nexus repository with maven build tool.
# Notes: Please ensure that your current account have register public key into "code.bonc.com.cn" and save it in ~/.ssh/rsa.pub
# Changes: support input directions for those three project to determinate building which project.
# Copyright: 2017(c) zhengwenqiang
# License: GPL
#-----------------------------------------------
propath=/home/hotspot/.autoBuild/project

war_box=/home/hotspot/.autoBuild/project/war_box

if [ -d $war_box ] ; then
    find $war_box -name '*.war' -type f -exec rm {} \;
else
    mkdir -p $war_box
fi

#cas_branch=multi_tenant_removed

#portal_branch=new_portal

#platform_branch=dev-1.0.6

if [ -f "$1" ] ; then
    sed -i 's/\r//g' $1
    source $1
else
    echo "Configuration File Not Found!"
    exit 0
fi

read -n 1 -p "Do you want to build security ?(Y|y|N|n):" isBuildSecurity
case $isBuildSecurity in
        Y|y)
        cd $propath
        [ -d platform ] || git clone ssh://git@code.bonc.com.cn:10022/base_framework/platform.git
        cd platform
        currentBranch=`git branch | grep ^\* | sed -r "s/\*\s//g"`
        if [ "$platform_branch" != "$currentBranch" ] ; then
                localBranchPlatform=`git branch | grep "^\s*$platform_branch$" | sed -r 's/\s*//g'`
                if [ -n $localBranchPlatform ] ; then
                        echo $localBranchPlatform"非空"
                        git checkout $platform_branch
                else
                        git checkout -b $platform_branch remotes/origin/$platform_branch
                fi
        else
                echo "Branch of platform is applicable now!"
        fi
        git pull
        cd security-base
        mvn clean install
        cd ../security
        mvn clean package -Pdeploy
        mv target/security.war $war_box
            ;;
       *)
            ;;
esac


read -n 1 -p "Do you want to build portal ?(Y|y|N|n):" isBuildPortal
case $isBuildPortal in
        Y|y)
        cd $propath
        [ -d portal ] || git clone ssh://git@code.bonc.com.cn:10022/base_framework/portal.git
        cd portal
        currentBranch=`git branch | grep ^\* | sed -r "s/\*\s//g"`
        if [ "$portal_branch" != "$currentBranch" ] ; then
            localBranchPortal=`git branch | grep "^\s*$portal_branch$" | sed -r 's/\s*//g'`
             if [ -n $localBranchPortal ] ; then
                        echo $localBranchPortal"非空"
                        git checkout $portal_branch
                else
                        git checkout -b $portal_branch remotes/origin/$portal_branch
                fi
        else
            echo "Branch of portal is applicable now!"
        fi
    
        git pull
        mvn clean package -Pdeploy
        mv target/portal.war $war_box
        ;;
    *)
        ;;
esac


read -n 1 -p "Do you want to build cas ?(Y|y|N|n):" isBuildCas
case $isBuildCas in
        Y|y)
    cd $propath
    [ -d cas ] || git clone ssh://git@code.bonc.com.cn:10022/base_framework/cas.git
    cd cas
    currentBranch=`git branch | grep ^\* | sed -r "s/\*\s//g"`
    if [ "$cas_branch" != "$currentBranch" ] ; then
        localBranchCas=`git branch | grep "^\s*$cas_branch$" | sed -r 's/\s*//g'`
        if [ -n $localBranchCas ] ; then
            echo $localBranchCas"非空"
            git checkout $cas_branch
        else
            git checkout -b $cas_branch remotes/origin/$cas_branch
        fi
    else
        echo "Branch of cas is applicable now!"

    fi
    git pull
    mvn clean package -Pdeploy
    mv target/cas.war $war_box
        ;;
    *)
        ;;
esac

 

转载于:https://www.cnblogs.com/zhengwenqiang/p/7249642.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值