当前位置:网站首页>Jenkins 中 shell 脚本执行失败却不自行退出
Jenkins 中 shell 脚本执行失败却不自行退出
2022-07-26 13:26:00 【测试界的飘柔】
Jenkins 中 执行 shell 脚本时,有时候 shell 执行失败了,或者判断结果是错误的,但是 Jenkins 执行完成后确提示成功 success 。
此时,可以通过条件判断来解决这个问题,让 Jenkins 强制退出并提示执行失败 failed 。
具体方法
jenkins 判断构建操作执行成功了还是失败了,可以通过返回 0 或 1 的结果。成功的话,返回0;否则,不成功返回1 。
比如 shell 脚本,通过 if 判断某个条件,最后,
成功:exit 0;不成功:exit 1 。
if [ $? -ne 0 ]; then
echo "=====failed====="
exit 1
else
echo "=====succeed====="
fi
脚本中的参数说明
$# 是传给脚本的参数个数
$0 是脚本本身的名字
$1 是传递给该shell脚本的第一个参数
$2 是传递给该shell脚本的第二个参数
[email protected] 是传给脚本的所有参数的列表
$* 是以一个单字符串显示所有向脚本传递的参数,与位置变量不同,参数可超过9个
$$ 是脚本运行的当前进程ID号
$? 显示最后命令(上个命令)的退出状态,0表示没有错误,其他表示有错误
现在我邀请你进入我们的软件测试学习交流群:【746506216】,备注“入群”, 大家可以一起探讨交流软件测试,共同学习软件测试技术、面试等软件测试方方面面,还会有免费直播课,收获更多测试技巧,我们一起进阶Python自动化测试/测试开发,走向高薪之路。
喜欢软件测试的小伙伴们,如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一 键三连哦!
软件测试工程师自学教程:
这才是2022最精细的自动化测试自学教程,我把它刷了无数遍才上岸字节跳动,做到涨薪20K【值得自学软件测试的人刷】
软件测试工程师月薪2W以上薪资必学技能 — Python接口自动化框架封装.
美团面试真题_高级测试25K岗位面试 — 软件测试人都应该看看
软件测试必会_Jmeter大厂实战 — 仅6步可实现接口自动化测试

边栏推荐
- HCIP第十一天比较(BGP的配置、发布)
- [flower carving hands-on] interesting and fun music visualization series small project (13) -- organic rod column lamp
- 同站攻击(相关域攻击)论文阅读 Can I Take Your Subdomain?Exploring Same-Site Attacks in the Modern Web
- 8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇
- Solve the problem that the remote host cannot connect to the MySQL database
- Concept and handling of exceptions
- 【花雕动手做】有趣好玩的音乐可视化系列小项目(13)---有机棒立柱灯
- Niuke brush sql---2
- Abstract factory and its improvement examples
- LeetCode 1523. 在区间范围内统计奇数数目
猜你喜欢

Photoshop(CC2020)未完

Team research and development from ants' foraging process (Reprint)

Learn about Pinia state getters actions plugins

一笔画问题(中国邮递员问题)

Solve the problem that the remote host cannot connect to the MySQL database

panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)

估值15亿美元的独角兽被爆裁员,又一赛道遇冷?

目标检测网络R-CNN 系列

Oom caused by improper use of multithreading

panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)
随机推荐
.NET WebAPI 使用 GroupName 对 Controller 分组呈现 Swagger UI
This article explains the FS file module and path module in nodejs in detail
With 8 years of product experience, I have summarized these practical experience of continuous and efficient research and development
SuperMap iclient for leaflet loads Gauss Kruger projection three-dimensional zonation CGCS2000 geodetic coordinate system WMTs service
Probability theory and mathematical statistics
12 brand management of commodity system in gulimall background management
云智技术论坛工业专场 明天见!
Using the geoprocessor tool
Photoshop (cc2020) unfinished
官宣!艾德韦宣集团与百度希壤达成深度共创合作
Outline design specification
Sword finger offer (x): rectangular coverage
Parent class reference to child class (parent class reference points to child class object)
JS object assignment problem
华为机考 ~ 偏移量实现字符串加密
B+树索引使用(8)排序使用及其注意事项(二十)
Solve the problem that the remote host cannot connect to the MySQL database
B+ tree index use (9) grouping, back to table, overlay index (21)
【Oauth2】五、OAuth2LoginAuthenticationFilter
[flower carving hands-on] interesting and fun music visualization series small project (13) -- organic rod column lamp
