我需要根据特定条件通过 jenkins post build 步骤发送一条 slack 消息。我已将以下代码片段放在我的 jenkins 构建的 Slack 通知的“自定义消息”下。下面打印了 get_schedule_response.txt 的全部内容。
Here's the result for the schedule execution --------> ${FILE,path="$WORKSPACE/get_schedule_response.txt"}
仅当 get_schedule_response.txt 文件内容包含文本 SUCCESS 时,我才想发送此 slack 通知。可以吗?
答案 0 :(得分:0)
使用grep命令你可以在文件get_schedule_response.txt文件中找到SUCESSS这个词
if [(grep -o "SUCCESS" "$WORKSPACE/get_schedule_response.txt"}) = "SUCCESS"];
then
#include your slack notification for success
else
#include your slack notification for success
# -o : Print only the matched parts of a matching line,
要参考 grep 命令的所有选项,请点击此链接