如题,多的话不说,直接上源码
1、SVN实现分支版本(copy)
if [ -z "${LOADED}" ]; then source ./env.conf fi if [ -z "${TO_VERSION}" ]; then echo "Usage:tag_all [-v svn_version -p project_name] to_version" exit 1 fi MAVENPRO="cportal${TO_VERSION}" if [ ! "${PROJECT_NAME}" == "" ]; then CPORTAL_TAG_PARENT_PATH="${PATH}/tags/cportal1.0.0/${MAVENPRO}" CPORTAL_TAG_PATH="${CPORTAL_TAG_PARENT_PATH}/${PROJECT_NAME}" CPORTAL_TRUNK_PATH="${PATH}/trunk/portal1.0.0/IECfmall/mavenPro/${PROJECT_NAME}" EXIST_TAG_PARENT_PATH=$(svn list ${CPORTAL_TAG_PARENT_PATH}|grep ${PROJECT_NAME}) else CPORTAL_TAG_PARENT_PATH="${PATH}/tags/cportal1.0.0" CPORTAL_TAG_PATH="${CPORTAL_TAG_PARENT_PATH}/${MAVENPRO}" CPORTAL_TRUNK_PATH="${PATH}/trunk/portal1.0.0/IECfmall/mavenPro" EXIST_TAG_PARENT_PATH=$(svn list ${CPORTAL_TAG_PARENT_PATH}|grep ${MAVENPRO}) fi
淘宝、天猫、聚划算,商家短期打造爆款,秒杀、咚咚抢、优惠券,应有尽有,只有您想不到,没有做不到,开心购呀购(网址:www.kxgba.com,微信小程序搜索:开心购呀购),您的购物好助手!
if [ -n "$EXIST_TAG_PARENT_PATH" ]; then echo "${CPORTAL_TAG_PATH} already exists" exit 1 fi if [ -z "$SVN_VERSION" ]; then echo "svn --username=username cp ${CPORTAL_TRUNK_PATH} ${CPORTAL_TAG_PATH}" svn --username=username cp ${CPORTAL_TRUNK_PATH} ${CPORTAL_TAG_PATH} -m "commit log" else echo "svn --username=username cp -r ${SVN_VERSION} ${CPORTAL_TRUNK_PATH} ${CPORTAL_TAG_PATH}" svn --username=username cp -r ${SVN_VERSION} ${CPORTAL_TRUNK_PATH} ${CPORTAL_TAG_PATH} -m "commit log" fi
2、SVN从TAG版本下载(checkout)
if [ -z "${LOADED}" ]; then source ./env.conf fi if [ -z ${TO_VERSION} ]; then echo "Usage:checkout_all [-p project_name] to_version" exit 1 fi if [ ! -d "$SRC_HOME" ]; then echo "==============create $SRC_HOME" mkdir -p $SRC_HOME fi cd $SRC_HOME #删除除最近3个版本的以前版本 ls -rt|head -n -3|xargs -i rm -rf {} check_success MAVENPRO="cportal${TO_VERSION}" if [ ! "${PROJECT_NAME}" == "" ]; then if [ ! -d "${SRC_HOME}/${MAVENPRO}" ]; then echo "==============create ${SRC_HOME}/${MAVENPRO}" mkdir -p ${SRC_HOME}/${MAVENPRO} fi cd "${SRC_HOME}/${MAVENPRO}" rm -rf ${PROJECT_NAME} CPORTAL_PATH="https://${PATH}/tags/cportal1.0.0/${MAVENPRO}/${PROJECT_NAME}" echo "svn checkout $CPORTAL_PATH" svn --username=username checkout $CPORTAL_PATH else cd $SRC_HOME rm -rf $MAVENPRO CPORTAL_PATH="https://${PATH}/tags/cportal1.0.0/${MAVENPRO}" echo "svn checkout $CPORTAL_PATH" svn --username=username checkout $CPORTAL_PATH $MAVENPRO fi
3、MAVEN编译及打包
if [ -z "${LOADED}" ]; then source ./env.conf fi if [ -z "${TO_VERSION}" ]; then echo "please input impl_all version" exit 1 fi echo "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&ALL impl execute start!!" echo "" #删除除最近3个版本的以前版本 cd ${DEPLOY_HOME} ls -rt|head -n -3|xargs -i rm -rf {} check_success
淘宝、天猫、聚划算,商家短期打造爆款,秒杀、咚咚抢、优惠券,应有尽有,只有您想不到,没有做不到,开心购呀购(网址:www.kxgba.com,微信小程序搜索:开心购呀购),您的购物好助手!
if [ -z "${PROJECT_NAME}" ]; then cd ${SRC_HOME}/cportal${TO_VERSION}/cportalaggregator else cd ${SRC_HOME}/cportal${TO_VERSION}/${PROJECT_NAME} fi mvn clean versions:set -DnewVersion=${TO_VERSION} mvn -U -Dmaven.test.skip=true -Dmaven.test.failture.ignore=true install if [ $? -ne 0 ]; then exit 1 fi echo "" DES_PATH="${DEPLOY_HOME}/cportal${TO_VERSION}/" if [ ! -d "$DES_PATH" ]; then mkdir -p $DES_PATH fi if [ "${PROJECT_NAME}" == "" ]; then cd ${SRC_HOME}/cportal${TO_VERSION} for pathname in cportal* do if [ "${pathname}" == "cportalaggregator" ]; then continue fi FILE_LIST=$(ls -l ${SRC_HOME}/cportal${TO_VERSION}/${pathname}/target/|grep ^-|awk '{print $9}') for file_name in ${FILE_LIST} do echo "cp ${SRC_HOME}/cportal${TO_VERSION}/${pathname}/target/${file_name} $DES_PATH" cp -rf ${SRC_HOME}/cportal${TO_VERSION}/${pathname}/target/${file_name} $DES_PATH done done else FILE_LIST=$(ls -l ${SRC_HOME}/cportal${TO_VERSION}/${PROJECT_NAME}/target/|grep ^-|awk '{print $9}') for file_name in ${FILE_LIST} do echo "cp -rf ${SRC_HOME}/cportal${TO_VERSION}/${PROJECT_NAME}/target/${PROJECT_NAME}-* ${DES_PATH}" cp -rf ${SRC_HOME}/cportal${TO_VERSION}/${PROJECT_NAME}/target/${PROJECT_NAME}-* ${DES_PATH} done fi echo "" echo "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&ALL impl execute end!!"
上述代码基础文件(env.conf):
if [ -z "${LOADED}" ]; then LOADED=1 fi HOME=/home/mh DEPLOY_HOME=$HOME/cportal1.0.0 LOG_HOME=$HOME/logs SRC_HOME=$HOME/src ARG_NUMBER=$# while [ ${ARG_NUMBER} -gt 0 ]; do case $1 in (-v) shift SVN_VERSION=$1 ;; (-p) shift PROJECT_NAME=$1 ;; (*) TO_VERSION=$1 break; ;; esac shift done #判断是否成功 check_success(){ if [ $? -ne 0 ]; then exit 1 fi } mvn_cmd(){ mvn -U -Dmaven.test.skip=true -Dmaven.test.failture.ignore=true } echo_info(){ echo "===================================================================================[$PROJECT_HOME/$1] execute end!!" } echo_interf_info(){ echo "[PROJECT LIST]" cd $PROJECT_HOME ls -ld VCPCOMMON && ls -ld *I echo "" }