jenkins 接入ding ding 發消息 原

使用Jenkins 接入 ding ding 給 釘釘羣發消息

python 代碼

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import json,urllib2,time,os,sys
cand_num=os.getenv('cand') #使用os.getenv 獲取Jenkins 參數
rom_version=os.getenv('rom_version')+"."+os.getenv('rom_version_x')
def Dintalk(cand,result,phone):
	url='https://oapi.dingtalk.com/robot/send?access_token=**********'
	if result ==1:
		con={"msgtype":"text","text":{"content":cand+"\n"},
		"at":{"atMobiles":phone,"isAtAll":"false"}}
	else:
		con={"msgtype":"text","text":{"content":cand+"\n"},
		"at":{"atMobiles":phone,"isAtAll":"true"}}
	jd=json.dumps(con)
	req=urllib2.Request(url,jd)
	req.add_header('Content-Type', 'application/json')
	response=urllib2.urlopen(req)
Dintalk('{0} 已經編譯好,存放路徑:\\\\192.168.0.188\\android\data\\binary\\alpha\\{1}\\{0}'.format(cand_num,rom_version),1,181******)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章