如果Jenkins' Build Passes'可以发送电子邮件。构建失败后?
是否可以发送电子邮件说构建已通过
答案 0 :(得分:0)
您可以在Jenkins中使用shell脚本来实现它。
CURRENT_BUILD_STATUS=$(curl --silent ${BUILD_URL}api/json | jq -r '.result')
prevBuildNo=$(($BUILD_NUMBER-1))
echo $prevBuildNo
PREVIOUS_BUILD_STATUS=$(curl -- silent http://jenkins.org.com/jenkins/job/job/jobname/${prevBuildNo}/api/json | jq -r '.result)
if ["$CURRENT_BUILD_STATUS" = "SUCCESS"] && ["$PREVIOUS_BUILD_STATUS" = "FAILED"]
then
#sending the mail
echo $ echo "hello world" | mail -s "a subject" someone@somewhere.com
else
echo "No e-mail trigger as the previous build was successful."
fi