jenkins 打包 命令

 

 jenkins 打包 命令_第1张图片

 

项目根目录需要一个 version.txt 

 

 

jenkins 打包 命令 

   
 

 

 

    jar 包

#!/bin/bash
set -x
# Initialize enviroment\
SVN_URL=http://127.0.0.1/opp/Project/07MavenSrc/JAVADemo/trunk
SVN_USER=baoyou
SVN_PSWD=baoyou
BASE_PATH=`pwd`


# Workspace directories
DIR_SRC=/root/workspace/JAVADemo
PAK_PATH=${DIR_SRC}/target


cd ${DIR_SRC}

VERSION=`cat version.txt |grep VERSION |cut -d = -f2`
BUILD_NUMBER=`cat version.txt |grep BUILDNUM |cut -d = -f2`

mvn clean install assembly:assembly findbugs:findbugs -Dmaven.test.skip=true

if [ ! $? = 0 ]
then
   echo "make compile  failed ,Please help to check "
   exit 1
fi
cd ${PAK_PATH}
PACKAGE=`ls |grep  *tar.gz`
echo " DNS_PACKAGE=$DNS_PACKAGE"
PACKAGE_FINAL=JAVADemo${VERSION}-`date +%Y%m%d%H%M`-${BUILD_NUMBER}.tar.gz
echo " PACKAGE_FINAL=$PACKAGE_FINAL"
mv $PACKAGE $PACKAGE_FINAL

finalVer=`expr $BUILD_NUMBER + 1`

 echo " finalVer=$finalVer"
 cd ${DIR_SRC}
 
sed -i "s/${BUILD_NUMBER}/${finalVer}/g"   version.txt


# Put the apk on ftp Server.
#Put apk from local to ftp server
if ping -c 3 127.0.0.1;then
echo "Ftp server works normally!"
else
echo "Ftp server is down again!"
exit 1
fi
#ftp login
ftp -nv <<EOC
open 127.0.0.1
user baoyou baoyou 
prompt
binary
cd /opp/local
cd ./JAVADemo
mkdir `date +%Y%m%d`
cd "`date +%Y%m%d`"
lcd ${PAK_PATH}
mput *.tar.gz

close
bye
EOC

echo "-> Done: Put aoe package file successfully!"

svn ci --username $SVN_USER --password $SVN_PSWD -m "OCT\nREM packaging $finalVer." $DIR_SRC/version.txt

 

war 包

   

mvn clean install war:war findbugs:findbugs -Dmaven.test.skip=true

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(命令,Jenkins,打包)