当前位置:网站首页>【jenkins】shell脚本调jenkins api接口
【jenkins】shell脚本调jenkins api接口
2022-06-22 10:14:00 【bulabula2022】
#使用列表for循环所要运行的job名
for variable in job1 job2 job3
do
#获取下一次构建编号
job_number=`curl --silent http://ip:port/job/$variable/api/json --user account:password |jq --raw-output '.nextBuildNumber'`
#执行job
curl -n -X POST http://ip:port/job/$variable/buildWithParameters --user --user account:password --data cp_branch='git分支'
#查询job状态最多循环执行5次
for i in `seq 1 5`
do
#查询间隔时间,60s,启动下一个job最长间隔5分钟
sleep 60
#获取当前job运行结果
##job_result=$(curl --silent http://ip:port/job/$variable/lastBuild/api/json --user account:password |jq --raw-output '.result')
job_result=`curl --silent http://ip:port/job/$variable/$job_number/api/json --user account:password |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
elif [[ $i = 5 ]] && [[ $job_result = "null" ]];then
echo "=================job:$variable构建超过5分钟,不等了,直接运行下一个job ==================="
else [[ $job_result = "null" ]]
echo "job_$variable构建中......"
fi
done
done
边栏推荐
- Pytorch实现波阻抗反演
- C language to write a two-way linked list
- 不要再傻傻分不清 hash、 chunkhash 和 contenthash 啦
- 6-40 constructing ordered sparse polynomial chained storage
- [LineCTF2022]BB
- 字节二面:Redis主节点的Key已过期,但从节点依然读到过期数据是为什么?怎么解决?
- px4代码学习之基于uavcan协议的时间同步消息中添加自定义字段
- LeetCode Algorithm 剑指 Offer 18. 删除链表的节点
- 代碼簽名證書一旦泄露 危害有多大
- [deep learning] tensorflow, danger! Google itself is the one who abandoned it
猜你喜欢

From in MySQL_ Unixtime and UNIX_ Timestamp processing database timestamp conversion - Case

Don't be silly enough to distinguish hash, chunkhash and contenthash

M2 芯片解析:似乎是一个增强版的 A15?

thinkphp3.2.3日志包含分析

【这款工具配合jmeter,会让你的工作效率至少提升80%,强烈推荐给大家】

Qt编写物联网管理平台36-通信协议

Thinkphp3.2.3 log inclusion analysis

一条TCP连接时占用内存空间多少?
![[LineCTF2022]BB](/img/9d/c5b0ce1e603d40efc5245ba074aa77.png)
[LineCTF2022]BB

Web Configuration of Visual Studio Code
随机推荐
Aliyun OS上证书签发过程(certbot)
HMS Core新闻行业解决方案:让技术加上人文的温度
2022各大厂最新总结的软件测试宝典,看完不怕拿不到offer
使用的软件是php mysql 数据库
Vs2022 connecting to SQLSERVER database tutorial
2022-06-09 工作记录--yarn/npm-Error-EPERM: operation not permitted, uv_cwd
Cobalt Strike 從入門到入獄(三)
[deep learning] great! The new attention makes the model 2-4 times faster!
Xidian AI ranked higher than Qingbei in terms of AI major, and Nantah ranked first in China in terms of Software Science in 2022
软件项目管理 8.3.敏捷项目质量活动
呼叫中心CTI系统
Cache penetration tool "Bloom filter"
TCP异常连接
MYSQL Skip Scan Range 小功能,解决大问题 ?
TCP 拥塞识别
Don't be silly enough to distinguish hash, chunkhash and contenthash
[LineCTF2022]BB
Advanced Web Zone record of attack and defense world (I)
CISP教材更新:2019年八大知识域新知识体系介绍
M2 芯片解析:似乎是一个增强版的 A15?