if [ $ENV == SIT ];then
ln -fs ../DEP-COMMON DEP-COMMON
echo " ====== start SIT ======================== "
echo "Change SIT configration now"
echo "add common jar file now"
cp -r DEP-COMMON/target/common-0.0.1-SNAPSHOT.jar lib/common-0.0.1-SNAPSHOT.jar
echo "List files under the directory"
#cd $WORKSPACE/lib && ls
echo "Change SIT application properties file now"
cp -r src/main/resources/properties/application_sit.properties src/main/resources/properties/application.properties
echo "Change SIT jdbc properties file now"
cp -r src/main/resources/properties/jdbc_sit.properties src/main/resources/properties/jdbc.properties
echo "delete _.properties"
rm -rf src/main/resources/properties/application_*
rm -rf src/main/resources/properties/jdbc_*
#bash change_common.sh
echo "Change log xml file now"
cp -r src/main/resources/logback.svr.xml src/main/resources/logback.xml
echo "delete logback.xml"
rm -rf src/main/resources/logback.svr.xml
echo " ====== End change_SIT_config shell done ========================= "
else
#bash change_PROD_config.sh;
ln -fs ../DEP-COMMON DEP-COMMON
echo "====== start PROD ========================"
echo "Change common configration now"
echo "add common jar file now"
cp -r DEP-COMMON/target/common-0.0.1-SNAPSHOT.jar lib/common-0.0.1-SNAPSHOT.jar
echo "List files under the directory"
#cd $WORKSPACE/lib && ls
echo "Change PROD application properties file now"
cp -r src/main/resources/properties/application_prod.properties src/main/resources/properties/application.properties
echo "Change PROD jdbc properties file now"
cp -r src/main/resources/properties/jdbc_prod.properties src/main/resources/properties/jdbc.properties
echo "delete _.properties"
rm -rf src/main/resources/properties/application_*
rm -rf src/main/resources/properties/jdbc_*
echo "Change log xml file now"
cp -r src/main/resources/logback.svr.xml src/main/resources/logback.xml
echo "delete logback.xml"
rm -rf src/main/resources/logback.svr.xml
echo " ====== End change_PROD_config shell done ========================= "
fi
自动构建部署
if [ $ENV == SIT ];then
echo " ====== start auto deployment SIT 83 ======================== "
mv /app/dep.tar /app/backup/dep.tar$(date +%Y%m%d_%H%M%S)
mv /app/backup/dep.tar /app/dep.tar
kill -9 $(ps -ef|grep "app/dep" |grep -v grep|awk '{print $2}')
rm -rf /app/dep
cd /app && tar -xf dep.tar
find /app/dep/bin/dep -type f |xargs sed -i '/# Attempt to set APP_HOME/i\export JAVA_HOME=\/app\/jdk\/jdk1.8.0_25'
find /app/dep/bin/dep -type f |xargs sed -i 's/exec "$JAVACMD"/exec nohup "$JAVACMD"/g' && find /app/dep/bin/dep -type f |xargs sed -i 's/DepStartup "$@"/DepStartup "$@" \>\/dev\/null 2\>\&1 \&/g' && cd /app/dep/bin/ && ls && ./dep
ps -ef | grep "/app"
else
echo " ====== Production environment is not automatically deployed ======================== "
fi