目标:
webhook推送过来消息-
-shell获取代码提交人-
-钉钉告知代码提交人代码已部署
需要首先解决linux中文乱码的问题
https://blog.csdn.net/weixin_39246787/article/details/80581496
a.建一个txt文件,建立手机号与人名的对应关系
b.获取代码提交人姓名
username=`git show -s --pretty=%an`
pushtime=`git show -s --pretty=%aD`
c.获取提交人对应的手机号
mobiles=`cat /opt/DingUserList.txt | grep "${username}=" | awk -F"=" '{print $2}'`
d.发送钉钉通知
curl 'https://oapi.dingtalk.com/robot/send?
access_token=aaasssdffffffffff'\
-H 'Content-Type: application/json; charset=utf-8'\
-d '{"msgtype": "text",
"text":
{"content": "'$JOB_NAME'提交的代码已部署\n"},
"at": {"atMobiles": ['${mobiles}'],
"isAtAll": false}}'