从零开始的Linux运维屌丝之路,资源免费分享平台   运维人员首选:简单、易用、高效、安全、稳定、社区活跃的开源软件

dingding推送消息webhook格式

发布:蔺要红05-27分类: 运维

# 普通
if [ "${myenv}" == "sho" ];then
    token=189f1d50ab7f3d8074b68760725440d96306da3465d4946507edb4b32c8ed6dac
else
    token=1d926aee0ab9d2663d03ec8698327c8f131cbc7c43f804f7f635e5db9884c27a1
fi
start_time=$(date '+%s')

DingSuccess () {
end_time=$(date '+%s')
user_time=$(expr $end_time - $start_time)s
curl 'https://oapi.dingtalk.com/robot/send?access_token='"${token}"'' \
-H 'Content-Type: application/json' -d '{"msgtype": "text", "text": {
"content": "'"项目名称:${project}
构建分支/tag:${branch_tag}
提交人员:${user_name}
状态:构建成功
构建时长:$user_time
时间:$(date +%F-%H:%M)
"'"}}'
}

DingError () {
end_time=$(date '+%s')
user_time=$(expr $end_time - $start_time)s
curl 'https://oapi.dingtalk.com/robot/send?access_token='"${token}"'' \
-H 'Content-Type: application/json' -d '{"msgtype": "text", "text": {
"content": "'"项目名称:${project}
构建分支/tag:${branch_tag}
提交人员:${user_name}
状态:构建过程中有错误,登陆 http://sh-js.vipthink.cn/job/prod/job/${project} 查看
构建时长:$user_time
时间:$(date +%F-%H:%M)
"'"}}'
}

# @ 人员

user_ip=1865390
user_name=1376301
access_token=6d002d3492a42b66134c8d46cfbf49783d6d9d373895c59282ae98573f5fd49c
# 如果text文本@的 手机号码不在,就会@ atMobiles列表里的人
curl 'https://oapi.dingtalk.com/robot/send?access_token='${access_token}'' -H 'Content-Type: application/json' -d '{"msgtype":"text","text":{
"content":"恢复
实例: '${user_ip}'
以下supervisor进程已恢复:'${user_name}'
@'${user_ip}'
"},
"at":{"atMobiles":
[
"1865390",
"1376301"
]
,"isAtAll": false
}}'

# 直接@ atMobiles
curl 'https://oapi.dingtalk.com/robot/send?access_token='${access_token}'' -H 'Content-Type: application/json' -d '{"msgtype":"text","text":{
"content":"恢复
实例: '${user_ip}'
以下supervisor进程已恢复:
"},
"at":{"atMobiles":
[
"'${user_ip}'",
"'${user_name}'"
]
}}'
 
温馨提示如有转载或引用以上内容之必要,敬请将本文链接作为出处标注,如有侵权我会在24小时之内删除!

欢迎使用手机扫描访问本站