#!/bin/sh #参数一要打包的项目名称 if [ $1 ]; then project_name=$1 else echo "请指定项目名称" exit 1 fi #参数二打包环境 if [ $2 ]; then echo "当前打包环境为${2}" env=$2 else echo "请指定打包环境 dev:开发环境,test:测试环境,prod:正式环境" exit 1 fi #代码不存在 则clone if [ ! -d "/data/code/${project_name}/" ];then cd /data/code/ git clone git@gitee.com:aixiaozao/${project_name}.git fi echo "更新${project_name}代码" cd /data/code/${project_name}/ git pull mvn clean install -Dmaven.test.skip=true -Denvironment=$env -U retval=$? if [ ${retval} -ne 0 ] ; then echo "/data/code/${project_name} 打包失败!" exit 1 else echo "/data/code/${project_name} 打包成功!" fi