1. [aulite.feishu]
    2. url = "https://open.larksuite.com/open-apis/bot/v2/hook"
    3. access_token = "xxxx"

    参数见飞书机器人说明

    1. class Feishu(object):
    2. def __init__(self, access_token, secret, url="https://open.feishu.cn/open-apis/bot/v2/hook/"):
    3. ...
    4. def send(self, data):
    5. """
    6. 发送消息
    7. :param data:
    8. :return:
    9. """
    10. headers = {'Content-Type': 'application/json'}
    11. url = self.get_url()
    12. logger.info(data)
    13. return requests.request("POST", url, headers=headers, data=json.dumps(data), verify=False)
    14. def send_message(self, title, text):
    15. """
    16. 发送消息
    17. :param title: 标题
    18. :param text: 文字
    19. :return:
    20. """
    21. data = {
    22. "msg_type": "post",
    23. "content": {
    24. "post": {
    25. "zh_cn": {
    26. "title": title,
    27. "content": [[{"tag": "text", "text": text}]
    28. ]
    29. }
    30. }
    31. }
    32. }
    33. return self.send(data)
    34. def send_lark_report(self, title, created_at, duration, env, summary, link, is_at_all=False, at_list=[]):
    35. """
    36. 发送lark报告
    37. :param title: 标题
    38. :param created_at: 创建时间
    39. :param duration: 总用时
    40. :param env: 环境
    41. :param summary: 用例执行情况
    42. :param link: 报告地址
    43. :param is_at_all: 是否@所有人
    44. :param at_list: @列表
    45. :return:
    46. """

    相关样式

    image.png

    报告动态配置:

    1. other_elements1 = [{'title': '资金统计', 'fields': [['测试前金额', total_asset_info['faitAssetResult']['totalAsset']]]}]
    2. self.settings.run.other_elements = other_elements1
    3. self.logger.error(self.settings.run.other_elements)

    应用机器人配置方法

    1. [aulite.robot]
    2. type = "feishu"
    3. func = "send_lark_report_by_enterprise"
    4. report_link = "xxxxxxx"
    5. [aulite.feishu]
    6. url = "https://open.larksuite.com"
    7. app_id = "xxxxxxx"
    8. app_secret = "xxxxxxx"
    9. app_verification_token = "xxxxxxx"
    10. chat_id = "oc_634bf156ec06eafaac4ed325f64729b3"

    获取群ID:
    https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/list

    获取应用信息:
    https://open.larksuite.com/app/