Linux shellスクリプト、CIパッケージについて

7259 ワード


#   $VMAXVERSION_ROOT_PATH  /home/version/package

# $SVN_URL  

#$DEV_VERSIONNO  V6.15.60.03B2

#http://10.5.70.3/ZXVMAX/CODE/dev/ZXVMAX/vmax-app-advanced/vmax-app-advanced-webapp/

directory=`pwd` 
copypath="$1"  #/home/version/package
SVNURL="$2" 
MARJORVERSIONNUM="$3"  #V6.15.60.03B2
echo $copypath

newversiontype=$(echo $(echo $SVNURL | awk -F"[/]" '{print $6}') | tr '[a-z]' '[A-Z]')
echo $newversiontype 

#     DEV,  newversiontype  V6.15.60.03B2,   BRANCH,       
if [ "$newversiontype"x = "DEV"x ];then
    newversionno=$MARJORVERSIONNUM
else
    if [ "$newversiontype"x = "BRANCH"x ];then
        newversionno=$(echo $(echo $SVNURL | awk -F"[/]" '{print $7}') | tr '[a-z]' '[A-Z]')
    else
        echo "version type error: version type is not DEV or BRANCH!"
        exit 1
    fi
fi
echo $newversionno

MAIN(){
    rm -rf vmax-app-advanced-webapp #          vmax-app-advanced-webapp
    echo "export the install package"
    if [ -e ./install ];then
        chmod 777 modify_advancedwebapp_version.sh
        ./modify_advancedwebapp_version.sh $newversionno
        svn export ./install ./vmax-app-advanced-webapp
    else
        echo "install directory is not exist,quit..."
        return
    fi

    fromret=`find ./target/scala-2.10 -name "vmax-app-advanced-webapp*war"`
    appname=`basename "$fromret" .zip`
    fromdir=`dirname "$fromret"`

    if [ -e "$fromret" ];then
        echo "find the $fromret"
    else
        echo "$fromret not exist,please check"
        return
    fi

    todir=./vmax-app-advanced-webapp/ums-server/procs/ppus/vmaxadvanced.ppu/vmaxadvanced-webapp.pmu/vmaxadvanced.ear
    toret=`find $todir -name "vmaxadvanced.war"`

    if [ -e "$toret" ];then    
        rm -rf "$toret"        
    fi

    mkdir $todir/vmaxsystem.war    
    unzip -o -d $todir/vmaxadvanced.war $fromret
    rm -rf $todir/vmaxadvanced.war/WEB-INF/lib/usf-*.jar

    cd vmax-app-advanced-webapp
    zip -r vmax-app-advanced-webapp-$newversionno.zip *

    cd "$directory"
    if [ ! -e $copypath/ictplugin ];then 
        mkdir $copypath/ictplugin
    fi      

    if [ -e ./vmax-app-advanced-webapp/vmax-app-advanced-webapp-$newversionno.zip ];then
        rm -rf $copypath/ictplugin/vmax-app-advanced-webapp-V*.zip
        mv ./vmax-app-advanced-webapp/vmax-app-advanced-webapp-$newversionno.zip $copypath/ictplugin/vmax-app-advanced-webapp-$newversionno.zip
    else
        echo "package vmax-app-advanced-webapp-$newversionno.zip file fail��quit..."
        return
    fi

    #cd ..
    rm -rf vmax-app-advanced-webapp
}

MAIN