环境python3.5+jenkins
# coding:utf-8
import urllib.request
import json
import sys
import time
import re
class dingHook(object):
def __init__(self,sys):
self.msg = sys.argv[1:]
self.url = "https://oapi.dingtalk.com/robot/send?access_token=30eee8d20287b0051d7c25cc6e468dcdd01XXXX"
def request(self, url, method, data=None, head={}):
request = urllib.request.Request(url=url, headers=head)
request.get_method = lambda: method
httpRes = urllib.request.urlopen(request, data)
content = httpRes.read()
httpRes.close()
return content
def post_start(self):
data = {}
data["msgtype"] = "text"
data["text"] = {}
data["text"]["content"] = " jenkins:开始执行{}自动