天天看點

jenkins接入企業微信提醒

1、可以簡單的在jenkins中安裝企業微信插件,直接配置,就可以直接通知

2、為了實際的需求可能要通知部分人或者通知内容要更改,這個時候我們可以自己手寫一個python腳本檔案,根據需求放在build前後執行就OK了。

#!/usr/bin/env python
import requests
import json

url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2aef68c3-9948-439e-ba10-xxxxxxx'

headers = {'content-type': "application/json", 'Authorization': 'APP appid = **,token = **'}

body = {
    "msgtype": "news",
    "news": {
       "articles" : [
           {
               "title" : "Test",
               "description" : "Successful",
               "url" : "www.baidu.com",
               "picurl" : "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png"
           }
        ]
    }
}
response = requests.post(url, data = json.dumps(body), headers = headers)