步驟一:
創建釘釘群,並配置機器人助手
步驟二:
配置安全設置:使用自定義關鍵詞方式
步驟三:
獲取Access_token和Webhook
步驟四:
Jenkins下載釘釘插件
步驟五:
Jenkins系統配置釘釘
步驟六
任務中配置釘釘要發送的內容
實際效果
Python腳本實現
import requests
import json
url = "https://oapi.dingtalk.com/robot/send?access_token=XXXXXX"
header = {'Content-Type': 'application/json'}
# 自定義關鍵詞設置了Test這個關鍵詞,故請求消息體中需包含Test字符串
body = {'msgtype': 'markdown',
'markdown': {
'title': 'IOS自動構建結果',
'text': '#### Test_IOS自動打包 \n> [下載地址](https://XXXXXXX) \n> '
}
}
if __name__ == '__main__':
re = requests.post(url=url, headers=header, data=json.dumps(body))