Jenkins的构建结果通知到飞书群
首先需要Post Build Task插件,在构建后操作里选择它,然后写入下方shell代码#!/bin/bashJOB_URL="${JENKINS_URL}job/${JOB_NAME}"getBuildState(){buildNr=$1curl -v ${JOB_URL}/${buildNr}/api/json --header 'Authorization: Basic YWRtaW46
·
首先需要Post Build Task插件,在构建后操作里选择它,然后写入下方shell代码
#!/bin/bash
JOB_URL="${JENKINS_URL}job/${JOB_NAME}"
getBuildState(){
buildNr=$1
curl -v ${JOB_URL}/${buildNr}/api/json --header 'Authorization: Basic YWRtaW46VWF0NjY2IQ==' | grep -Po '"result":\s*"\K\w+'
}
state=$(getBuildState ${BUILD_NUMBER} )
string1=$BUILD_DISPLAY_NAME
string2=$JOB_BASE_NAME
nowTime=$(date "+%Y-%m-%d %H:%M:%S")
echo $state
if [[ "x${state}" == "xSUCCESS" ]] ; then
curl -X POST -H "Content-Type: application/json" \
-d '{"msg_type":"post","content": {"post": {"zh_cn": {"title": "发布结果通知","content": [[{"tag": "text","text": "'"应用:本群通知专用\n系统:$string2\n构建:$string1\n状态:成功\n日期:$nowTime"'"}]]} } }}' \
https://这里加上飞书群机器人Hook就OK!
else
curl -X POST -H "Content-Type: application/json" \
-d '{"msg_type":"text","content":{"text":"'"应用:本群通知专用\n系统:$string2\n构建:$string1\n状态:失败\n日期:$nowTime"'"}}' \
https://这里加上飞书群机器人Hook就OK!
fi
更多推荐
已为社区贡献1条内容
所有评论(0)