#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import requests
import os


Job_name = os.getenv("JOB_NAME")
Job_num = os.getenv("BUILD_NUMBER")
JOB_URL = 'http://xxxxxxxx' + '/job' + '/{}'.format(Job_name) + '/{}'.format(Job_num) + '/consoleText'
url = 'https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx'
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": "任务名称:" + "{}".format(Job_name) + "\n任务编号:" + "{}".format(Job_num),
                "tag": "lark_md"
            }
        }, {
            "actions": [{
                "tag": "button",
                "text": {
                    "content": "查看发布报告",
                    "tag": "lark_md"
                },
                "url": JOB_URL,
                "type": "default",
                "value": {}
            }],
            "tag": "action"
        }],
        "header": {
            "title": {
                "content": "程序已发布",
                "tag": "plain_text"
            }
        }
    }
}
requests.request(method=method, url=url, headers=headers, json=json)



Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐