|
@@ -10,11 +10,26 @@ import json
|
|
|
|
|
|
import requests
|
|
|
from . import Notice
|
|
|
+from walle.model.project import ProjectModel
|
|
|
|
|
|
|
|
|
class Dingding(Notice):
|
|
|
|
|
|
def deploy_task(self, project_info, notice_info):
|
|
|
+ if notice_info['repo_mode'] == ProjectModel.repo_mode_tag:
|
|
|
+ version = notice_info['tag']
|
|
|
+ else:
|
|
|
+ version = '%s/%s' % (notice_info['branch'], notice_info['commit'])
|
|
|
+ data = {
|
|
|
+ "msgtype": "markdown",
|
|
|
+ "markdown": {
|
|
|
+ "title": "上线单通知",
|
|
|
+ "text": """####  %s %s \n> **项目**:%s \n
|
|
|
+ > **任务**:%s \n
|
|
|
+ > **版本**:%s \n """ % (
|
|
|
+ notice_info['username'], notice_info['title'], notice_info['project_name'], notice_info['task_name'],
|
|
|
+ version)}
|
|
|
+ }
|
|
|
'''
|
|
|
上线单新建, 上线完成, 上线失败
|
|
|
|
|
@@ -29,19 +44,8 @@ class Dingding(Notice):
|
|
|
'is_branch',
|
|
|
@return:
|
|
|
'''
|
|
|
- data = {
|
|
|
- "msgtype": "markdown",
|
|
|
- "markdown": {
|
|
|
- "title": "上线单通知",
|
|
|
- "text": """####  %s %s \n> **项目**:%s \n
|
|
|
- > **任务**:%s \n
|
|
|
- > **分支**:%s \n
|
|
|
- > **版本**:%s \n """ % (
|
|
|
- notice_info['username'], notice_info['title'], notice_info['project_name'], notice_info['task_name'],
|
|
|
- notice_info['branch'], notice_info['commit'])
|
|
|
- }
|
|
|
- }
|
|
|
headers = {'Content-Type': 'application/json;charset=UTF-8'}
|
|
|
- response = requests.post(project_info['notice_hook'], data=json.dumps(data).encode('utf-8'), headers=headers)
|
|
|
+ for hook in project_info['notice_hook'].split(','):
|
|
|
+ response = requests.post(hook, data=json.dumps(data).encode('utf-8'), headers=headers)
|
|
|
|
|
|
return response.json()['errcode'] == 0
|