jenkins典型配置-多分支选择

 

 

 

 

 

 

 

 

 

 

 

[root@java_test dfs]# cat service.sh
#!/bin/bash

jar=$1

scp /dfs/server/$1 root@192.168.115.68:/dfs/server/

sleep 2

pid=`ps aux | grep java |grep $jar | grep -v grep | awk '{print $2}'`
if [[ "$pid" ]];then
echo "----------进程号:$pid"
echo "----------杀掉 $jar"
kill $pid
sleep 3
else
echo "------------$jar not running"
fi

echo "----------启动 $jar"

if [[ "$jar" == "news-content-1.0-SNAPSHOT.jar" ]]; then
agentid=content115103
appname=test-content-115-103
workpath=/dfs/java/news/

elif [[ "$jar" == "common-service-1.0-SNAPSHOT.jar" ]]; then
agentid=common-service115103
appname=test-common-service-115-103
workpath=/dfs/java/news/
elif [[ "$jar" == "resource-1.0-SNAPSHOT.jar" ]]; then
agentid=resourceservice115103
appname=test-resource-service-115-103
workpath=/dfs/java/news/

elif [[ "$jar" == "app-1.0-SNAPSHOT.jar" ]]; then
agentid=app115103
appname=test-app-115-103
workpath=/dfs/java/news/
elif [[ "$jar" == "news-search-1.0-SNAPSHOT.jar" ]]; then
agentid=search115103
appname=test-search-115-103
workpath=/dfs/java/news/

elif [[ "$jar" == "news-user-1.0-SNAPSHOT.jar" ]]; then
agentid=user115103
appname=test-user-115-103
workpath=/dfs/java/news/

elif [[ "$jar" == "news-manage-1.0-SNAPSHOT.jar" ]]; then
agentid=manage115103
workpath=/dfs/java/news/
appname=test-manage-115-103

elif [[ "$jar" == "news-payment-1.0-SNAPSHOT.jar" ]]; then
agentid=payment115103
workpath=/dfs/java/news/
appname=test-payment-115-103

elif [[ "$jar" == "news-activity-1.0-SNAPSHOT.jar" ]]; then
agentid=activity115103
workpath=/dfs/java/news/
appname=test-activity-115-10

elif [[ "$jar" == "m-eps-1.0-SNAPSHOT.jar" ]]; then
agentid=eps115103
workpath=/dfs/java/news/
appname=test-eps-115-103

elif [[ "$jar" == "m-wemedia-1.0-SNAPSHOT.jar" ]]; then
agentid=wemedia115103
workpath=/dfs/java/news/
appname=test-wemedia-115-103

elif [[ "$jar" == "news-comment-1.0-SNAPSHOT.jar" ]]; then
agentid=comment115103
workpath=/dfs/java/news/
appname=test-comment-115-103
elif [[ "$jar" == "discovery-0.0.1-SNAPSHOT.jar" ]]; then
agentid=discovery115103
workpath=/dfs/java/news-cloud/
appname=test-discovery-115-103
elif [[ "$jar" == "gateway-0.0.1-SNAPSHOT.jar" ]]; then
agentid=gateway115103
workpath=/dfs/java/news-cloud/
appname=test-gateway-115-103
elif [[ "$jar" == "config-0.0.1-SNAPSHOT.jar" ]]; then
agentid=config115103
workpath=/dfs/java/news-cloud/
appname=test-config-115-103
elif [[ "$jar" == "zipkin-0.0.1-SNAPSHOT.jar" ]]; then
agentid=zipkin115103
workpath=/dfs/java/news-cloud/
appname=test-zipkin-115-103

elif [[ "$jar" == "quartz-1.0-SNAPSHOT.jar" ]];then
agentid=quartz115103
appname=test-quartz-115-103
workpath=/dfs/java/news/
else
exit
fi

echo $agentid
echo $appname
DATE=`date +"%Y-%m-%d_%H_%M"`
mv $workpath$jar /dfs/bkjar/${DATE}_${jar}

mv /dfs/server/$jar $workpath

#cd $workpath && nohup java -jar $jar --spring.profiles.active=test >/dev/null 2>&1 &
cd $workpath && nohup java -Xms2048m -Xmx2048m -jar $jar --spring.profiles.active=test >/dev/null 2>&1 &
sleep 3
P=`ps aux | grep java |grep $jar | grep -v grep | awk '{print $2}'`
if [[ "$P" ]];then
echo "--------进程号:$P"
echo "--------启动成功"
else
echo "启动失败"
fi
#cd $workpath && nohup java -javaagent:/data/agent/pinpoint-bootstrap-1.7.1.jar -Dpinpoint.agentId=$agentid -Dpinpoint.applicationName=$appname -jar $jar --spring.profiles.active=test >/dev/null 2>&1 &
var=$1
file=`echo ${var%-*}`
echo "$file"
pub_time=`date +"%Y-%m-%d %H:%M:%S"`
text="测试环境$file 发布完成"
echo $text
curl 'https://oapi.dingtalk.com/robot/send?access_token=e6f80057a6cc805a7865e0399dd43268e6a6d70866f920a780fb1262e106e79f' \
-H 'Content-Type: application/json' \
-d '
{"msgtype": "text",
"text": {
"content": "'"$text"'"
},
"at": {
"isAtAll": true
}
}'

 

 

posted on 2019-07-31 08:35  net2817  阅读(1977)  评论(0编辑  收藏  举报

导航