当前位置:网站首页>【shell】jenkins shell实现自动部署
【shell】jenkins shell实现自动部署
2022-06-29 13:49:00 【bulabula2022】
1.查看工程编译打包是否自动完成
#!/bin/bash
# 将本地命令行运行job
#curl -n -X POST http://XXX:8089/job/scev6/buildWithParameters --user xxxx:1234abcd --data cp_branch='stage-mom'
#获取jenkins 控制台日志
#curl -n -X POST http://XXX:8089/job/scev6/$job_number/consoleText --user xxxx:1234abcd
#使用列表for循环所要运行的job名,按照列表里先后顺序执行,不可更改
for variable in scev6 scev6-multilang
do
#获取下一次构建编号
job_number=`curl --silent http://XXX:8089/job/$variable/api/json --user xxx:1234abcd |jq --raw-output '.nextBuildNumber'`
#执行job,分支选择stage-mom,也即是10.79.69.21
curl -n -X POST http://XXX:8089/job/$variable/buildWithParameters --user XXX:1234abcd --data cp_branch='stage'
#查询job状态最多循环执行5次
for i in `seq 1 5`
do
#查询间隔时间60s,启动下一个job,最长间隔5分钟
sleep 60
#获取当前job运行结果
##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 "=================第$i次检测当前job:${variable},job编号:$job_number,job运行状态: $job_result ====================================="
if [[ $job_result = "SUCCESS" ]];then
echo "=================job:$variable构建完成,运行下一个 ==================="
break
elif [[ $job_result = "FAILURE" ]] || [[ $job_result = "ABORTED" ]];then
echo "=================job:$variable构建失败,运行下一个 ==================="
break
else [[ $job_result = "null" ]]
echo "job_$variable构建中......"
fi
done
done
2.上传打包后的工程到腾讯云服务器
#!/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 '传输文件到腾讯云服务器(124.223.62.51)上完成......'3.启动服务
#!/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'
边栏推荐
- 深度学习的坎坷六十年
- Introduction to esp8266: three programming methods "suggestions collection"
- 东莞虎门券商公司股票开户哪个更好更安全?
- Tiktok's global short video dominance may be reversed by YouTube
- zabbix 5.0如何将esxi6.7添加到监控
- 台式机主板上保护cpu的盖子安装和拆卸
- What is the reason why the gbase8s database encountered a 951 error?
- Intuition and Implementation: batch normalization
- goby全端口扫描
- win10安装Monggodb的基本使用教程
猜你喜欢

【黑马早报】中公教育市值蒸发逾2000亿;新东方直播粉丝破2000万;HM关闭中国首店;万科郁亮称房地产已触底;微信上线“大爆炸”功能...

Wechat applet: repair collection interface version cloud development expression package

Stable currency risk profile: are usdt and usdc safe?

I talked about exception handling for more than half an hour during the interview yesterday

台式机主板上保护cpu的盖子安装和拆卸

节点数据采集和标签信息的远程洪泛传输

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

mysql多表查询

win11怎么看cpu几核几线程? win11查看cpu是几核几线程的教程

微信小程序:(更新)云开发微群人脉
随机推荐
vmware虚拟机的作用
Thinkpad VMware 安装虚拟机出现此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态(问题解决方法)
灵感收集·创意写作软件评测:Flomo、Obsidian Memo、Napkin、FlowUs
win11怎么看cpu几核几线程? win11查看cpu是几核几线程的教程
VeeamBackup&Replication简介
Hash hash game system development explanation technology -- hash game system development solution analysis
Unity 关于Destroy 和 OnDestroy失效(延迟)的问题
“死掉”的诺基亚,一年躺赚1500亿
强大、优秀的文件管理软件评测:图片管理、书籍管理、文献管理
【重要通知】中国图象图形学学会2022年度系列奖励推荐工作启动
systemd调试
How goby exports scan results
MySQL 1146 error [easy to understand]
Redis fragment cluster setup and use tutorial
How to install MySQL 8.0 on rocky Linux and almalinux
微信小程序:图片秒加水印制作生成
MySQL数据库:读写分离
Wechat applet: install B artifact and P diagram, modify wechat traffic main applet source code, Download funny joke diagram, make server free domain name
NuScenes关于Radar的配置信息
tcpdump如何对特定的tcp标志位进行过滤