maven deploy configuration

本文介绍如何配置Maven项目的pom.xml文件以使用Archiva作为仓库,并提供了一个用于从该仓库部署应用程序包的bash脚本示例。

in pom.xml, the config will be below:

<repositories>
		<repository>
			<id>com.nomura.xxx</id>
			<url>http://XXXXXXX:8080/archiva/repository</url>
		</repository>
	</repositories>



	
	<distributionManagement>
		<repository>
			<id>XXXX.release</id>
			<name>xxxxRelease Repository</name>
			<url>http://XXXXX/archiva/repository/release/</url>
		</repository>
		<snapshotRepository>
			<id>XXXXX.snapshot</id>
			<name>Internal Snapshot Repository</name>
			<url>http://XXXXX/archiva/repository/snapshot/</url>
		</snapshotRepository>
	</distributionManagement>

 

In the app workspace, you can input the command:

mvn deploy

 

to deploy the app into the share server.

 

And in the server that run the app, you can run below script to get app package.
deploy APPNAME VERSION

 

the scripts content will be :

 

#!/bin/bash

set -e
set -u

OUR_HOME="`dirname "$0"`/"

REPO_ROOT="http://XXXXX/archiva/repository/"

COMPONENT="$1"
VERSION="$2"


echo "Using REPO_PREFIX: $REPO_PREFIX"

INSTALL_ROOT="${HOME}"
INSTALL_COMPONENT_ROOT="${INSTALL_ROOT}/${COMPONENT}"

mkdir -p "${INSTALL_COMPONENT_ROOT}"

TMP_DIR=/tmp/VenomComponentZip/${COMPONENT}-`date -u "+%Y-%m-%d-%H:%M:%S.%N"`
mkdir -p $TMP_DIR


########################################
# Special handling for TomCat Components
########################################
if [ ${COMPONENT} == "FXAllocationsUI" -o ${COMPONENT} == "TraderClientPnL" ] ; then

    wget -nv -P ${INSTALL_COMPONENT_ROOT} "${REPO_ROOT}/${REPO_PREFIX}/${COMPONENT}/${VERSION}/${COMPONENT}-${VERSION}.war"
    pushd $INSTALL_COMPONENT_ROOT
    rm -f ${COMPONENT}.war
    ln -s ${COMPONENT}-${VERSION}.war ${COMPONENT}.war

    rm -rf $TMP_DIR

    exit
fi


##################################
# Special handling foHome
##################################
if [[ ${COMPONENT} == "xxxHome" ]]
    then
    #Special handling for xxxHome which is not a Java component
    case $USER in
    eufxcdev)
        ENVIRONMENT=dev
        ENVIRONMENT_NAME=test.ln;;
    eufxcstg)
        ENVIRONMENT=stage
        ENVIRONMENT_NAME=stage.ln;;
    eufxcprd)
        ENVIRONMENT=prod
        ENVIRONMENT_NAME=prod.ln;;
    *)
        echo "Error calculating environment based on current user $USER"
        EXIT 3
    esac

    xxxHOME_ZIP_FILENAME=${COMPONENT}-${VERSION}-${ENVIRONMENT}.zip

    wget -nv -P $TMP_DIR "${REPO_ROOT}/${REPO_PREFIX}/${COMPONENT}/${VERSION}/${xxxHOME_ZIP_FILENAME}"

    unzip -d $TMP_DIR $TMP_DIR/$xxxHOME_ZIP_FILENAME "xxxHome/$ENVIRONMENT_NAME/*"

    TARGET_DIRECTORY=$INSTALL_COMPONENT_ROOT/${ENVIRONMENT_NAME}-$VERSION

    if [ -e "$TARGET_DIRECTORY" ] ; then
        echo "xxxHome version is already deployed. Delete it if you want a redeploy: $TARGET_DIRECTORY"
        echo "Please manually remove the soft link from the home directory and point to the required version."
        exit 26
    fi

    mv $TMP_DIR/xxxHome/$ENVIRONMENT_NAME $TARGET_DIRECTORY

    if [[ $ENVIRONMENT == "dev" ]]
    then
        echo "Not setting soft link $ENVIRONMENT_NAME. In the development environment, xxxHome is taken from SVN"
    else
        echo "Deleting and recreating soft link: $ENVIRONMENT_NAME"
        pushd $INSTALL_COMPONENT_ROOT
        rm -f ${ENVIRONMENT_NAME}
        ln -s ${ENVIRONMENT_NAME}-$VERSION ${ENVIRONMENT_NAME}
    fi

    rm -rf $TMP_DIR

    exit #Finished processing for xxxHome
fi
########################################
# END - Special handling for xxxHome
########################################


wget -nv -P $TMP_DIR "${REPO_ROOT}/${REPO_PREFIX}/${COMPONENT}/${VERSION}/${COMPONENT}-${VERSION}-Server.zip"

unzip "$TMP_DIR/${COMPONENT}-${VERSION}-Server.zip" -d "${INSTALL_COMPONENT_ROOT}"
$OUR_HOME/moveJarsToShared ${INSTALL_COMPONENT_ROOT}/${COMPONENT}-${VERSION}/lib ${COMPONENT}-${VERSION}

if [ $? -eq 0 ] ; then
    function noSelector {
        echo "No Selector zip for this project"
        NO_SELECTOR=true
    }
    #Don't fail and exit the script if we get a 404 on the file. It's a valid condition to have no selector zip.
    NO_SELECTOR=false
    wget -nv -q -P $TMP_DIR "${REPO_ROOT}/${REPO_PREFIX}/${COMPONENT}/${VERSION}/${COMPONENT}-${VERSION}-Selector.zip" || noSelector

    if [ $NO_SELECTOR == false ] ; then
        echo "Selector zip is present"
        unzip "$TMP_DIR/${COMPONENT}-${VERSION}-Selector.zip" -d "${INSTALL_COMPONENT_ROOT}"
    fi

    echo "Creating soft link called live pointing to the newly deployed version"
    pushd ${INSTALL_COMPONENT_ROOT}
    rm -f live
    ln -s ${COMPONENT}-$VERSION live
    popd
fi

rm -rf $TMP_DIR
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值