我想编写一个脚本,当url的状态不等于200时抛出错误.因为这个脚本必须在Jenkins上执行所以它应该使构建失败.这是我写的脚本 -
STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://google.com)
if [ $STATUS -eq 200 ]; then
echo "URL is working fine"
break
else
echo"URL is not working"
cd 123
fi
Run Code Online (Sandbox Code Playgroud)
上面的脚本工作正常,但我需要别的东西而不是-cd 123语法.
但我需要别的东西而不是-cd 123语法
你可以说:
exit 42
Run Code Online (Sandbox Code Playgroud)
代替.这将使脚本以非零退出代码退出,该代码应由Jenkins选取.
help exit 讲述:
exit: exit [n]
Exit the shell.
Exits the shell with a status of N. If N is omitted, the exit status
is that of the last command executed.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6977 次 |
| 最近记录: |