项目根目录需要一个 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
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。
个人主页:http://knight-black-bob.iteye.com/
谢谢您的赞助,我会做的更好!