jenkins配置飞书机器人通知

1.在飞书群里创建一个机器人,记住webhook
jenkins配置飞书机器人通知_第1张图片
2.写python脚本

import sys

import requests

JOB_URL = sys.argv[1]
url = '这里写webhook'
method = 'post'
headers = {
    'Content-Type': 'application/json'
}
json = {
    "msg_type": "interactive",
    "card": {
        "config": {
            "wide_screen_mode": True,
            "enable_forward": True
        },
        "elements": [{
            "tag": "div",
            "text": {
                "content": "接口自动化测试完成,可以继续后续验证。",
                "tag": "lark_md"
            }
        }, {
            "actions": [{
                "tag": "button",
                "text": {
                    "content": "查看测试报告",
                    "tag": "lark_md"
                },
                "url": JOB_URL + "allure",
                "type": "default",
                "value": {}
            }],
            "tag": "action"
        }],
        "header": {
            "title": {
                "content": "大家好",
                "tag": "plain_text"
            }
        }
    }
}
requests.request(method=method, url=url, headers=headers, json=json)

3.jenkins配置
jenkins配置飞书机器人通知_第2张图片
4.查看成果
jenkins配置飞书机器人通知_第3张图片

jenkins配置飞书机器人通知_第4张图片

你可能感兴趣的:(笔记,jenkins,python)