当前位置:网站首页>[shell] Jenkins shell realizes automatic deployment
[shell] Jenkins shell realizes automatic deployment
2022-06-29 14:19:00 【bulabula2022】
1. Check whether the project compilation and packaging are completed automatically
#!/bin/bash
# Run the local command line job
#curl -n -X POST http://XXX:8089/job/scev6/buildWithParameters --user xxxx:1234abcd --data cp_branch='stage-mom'
# obtain jenkins Console log
#curl -n -X POST http://XXX:8089/job/scev6/$job_number/consoleText --user xxxx:1234abcd
# Use list for What the loop is going to run job name , Follow the order in the list , Non modifiable
for variable in scev6 scev6-multilang
do
# Get the next build number
job_number=`curl --silent http://XXX:8089/job/$variable/api/json --user xxx:1234abcd |jq --raw-output '.nextBuildNumber'`
# perform job, Branch selection stage-mom, That is to say 10.79.69.21
curl -n -X POST http://XXX:8089/job/$variable/buildWithParameters --user XXX:1234abcd --data cp_branch='stage'
# Inquire about job The state can execute in cycles at most 5 Time
for i in `seq 1 5`
do
# Query interval 60s, Start the next job, Maximum interval 5 minute
sleep 60
# Get current job Running results
##job_result=$(curl --silent http://XXX:8089/job/$variable/lastBuild/api/json --user XXX:1234abcd |jq --raw-output '.result')
job_result=`curl --silent http://XXX:8089/job/$variable/$job_number/api/json --user XXX:1234abcd |jq --raw-output '.result'`
echo "================= The first $i Detection current job:${variable},job Number :$job_number,job Running state : $job_result ====================================="
if [[ $job_result = "SUCCESS" ]];then
echo "=================job:$variable Build complete , Run next ==================="
break
elif [[ $job_result = "FAILURE" ]] || [[ $job_result = "ABORTED" ]];then
echo "=================job:$variable Build failed , Run next ==================="
break
else [[ $job_result = "null" ]]
echo "job_$variable In the building ......"
fi
done
done
2. Upload the packaged project to Tencent ECs
#!/bin/bash
vdate=`date +'%Y%m%d%H%M%S'`
tg="v${vdate}_${BUILD_NUMBER}"
port=22
[email protected]
#pwd="cobbler"
pwd=/home/devops/.ssh/id_rsa
cmd="sudo rsync -avP -e \"ssh -i /root/.ssh/id_rsa\" /mnt/scev6/war/ [email protected]:/mnt/scev6/war/ --include=/* --include=*.jar --include=*.war --exclude=*"
ssh -p $port -i $pwd $target "$cmd"
#ssh -p 22 -i /home/devops/.ssh/id_rsa [email protected]
echo ' Transfer files to Tencent ECS (124.223.62.51) The complete ......'3. Start the service
#!/bin/bash vdate=`date +'%Y%m%d%H%M%S'` tg="v${vdate}_${BUILD_NUMBER}" port=22 [email protected] #srcdir="/mnt/deployment/mom-server/src" pwd=xxx cmd="sudo bash /mnt/scev6/b.sh restart && sudo bash /mnt/scev6/a.sh restart" ssh -p $port $target "$cmd" #ssh -p 22 -i xxx [email protected] echo 'end'
边栏推荐
- golang代码规范整理
- 28000 word summary of callable and future interview knowledge points. After reading it, I went directly to ByteDance. Forgive me for being a little floating (Part 2)
- VQA不只需要图片,还需要外部知识!华盛顿大学&微软提出提出REVIVE,用GPT-3和Wikidata来辅助回答问题!...
- 投资人跌下神坛:半年0出手,转行送外卖
- 【 网络带宽 】MBps & Mbps
- golang6 反射
- Thanos Store 组件
- [document translation] camouflaged object detection
- Hardware development notes (VIII): basic process of hardware development, making a USB to RS232 module (VII): creating a basic dip component (crystal oscillator) package and associating the principle
- Why does ETL often become ELT or even let?
猜你喜欢

纳人才,谋发展 | 人大金仓喜获“最佳雇主校招案例奖”

数字IC手撕代码--交通灯

微信小程序:装B神器P图修改微信流量主小程序源码下载趣味恶搞图制作免服务器域名

Wechat applet: Halloween avatar box generation tool

Goby full port scan

goby如何导出扫描结果

靠代理,靠买断,国产端游的蛮荒时代等待下一个《永劫无间》

分布式唯一 ID 生成方案浅谈

Wechat applet: install B artifact and P diagram, modify wechat traffic main applet source code, Download funny joke diagram, make server free domain name

逆向调试入门-PE文件节表与区块03/07
随机推荐
【VEUX开发者工具的使用-getters使用】
Redis fragment cluster setup and use tutorial
Intuition and Implementation: batch normalization
Redis master-slave replication principle
goby如何导出扫描结果
zabbix 5.0如何将esxi6.7添加到监控
分布式唯一 ID 生成方案浅谈
广州开展瓶装气安全宣传活动,普及燃气安全知识
Equivalence class partition method for test case design method
[high concurrency] 28000 words' summary of callable and future interview knowledge points. After reading it, I went directly to ByteDance. Forgive me for being a little drifting (Part 1)
MySQL数据库:drop、truncate、delete的区别
Investors fell off the altar: 0 sales in half a year, transferred to business and delivered takeout
Go unit testing introductory practice
By proxy, by buyout, the wild era of domestic end-to-end travel is waiting for the next "eternal robbery"
goby全端口扫描
Crazy digital collections, the next myth of making wealth?
Wechat applet: Yunkai publishes white wall wechat applet source code download server free and domain name support traffic main revenue
[dark horse morning post] the market value of China public education has evaporated by more than 200billion; New Oriental has more than 20million live fans; HM closes its first store in China; Vanke Y
投资人跌下神坛:半年0出手,转行送外卖
揭秘百度智能测试在测试自动执行领域实践