我希望能够从我的构建后脚本中读取构建脚本的退出代码。有没有办法在 Jenkins 配置中做到这一点?
它将允许我检查匹配的字符串(在本例中为“hella success rn”),但它不会让我看到构建脚本的退出代码?
我希望能够从我的构建后脚本中读取构建脚本的退出代码。有没有办法在 Jenkins 配置中做到这一点?
它将允许我检查匹配的字符串(在本例中为“hella success rn”),但它不会让我看到构建脚本的退出代码?
您可以#!/bin/sh
在块的开头使用,Execute shell
如下所示:
在没有 Jenkins使用#!/bin/sh
的默认选项的情况下使用 ie,#!/bin/sh -xe
将防止Jenkins 将您标记Execute shell
为失败。这样做将帮助您运行查找脚本返回状态的后续命令。
-e Exit immediately if a command exits with a non-zero status.
参考: http: //linuxcommand.org/lc3_man_pages/seth.html
根据script_status=$?
脚本的返回状态 ( ),打印一些您可以稍后在构建后步骤中搜索的内容。
然后,在 中Post-build Actions
,搜索该打印文本以决定您的构建后操作,如下所示:
输出: