当前位置:网站首页>Jenkins linked flybook pushes the test report notification message in the form of signature verification
Jenkins linked flybook pushes the test report notification message in the form of signature verification
2022-07-20 08:20:00 【⎛⎝⎠⎞ world】
1、 obtain anonymous letter Bot webhook and secret.
2、python Script , Reference resources @Song_Estelle The article , Here we rewrite part of the code , Send notification by signature verification ( Remember to install related dependencies ).
#! /usr/bin/python3
#-*- encoding: utf-8 -*-
import sys
import requests
import time
import hmac
import base64
import hashlib
from datetime import datetime
class JenkinsInfo(object):
def __init__(self, feis_webhook, feis_secret, job_url, job_name, build_number):
self.feis_webhook = feis_webhook
self.feis_secret = feis_secret
self.currenttime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
self.timestamp = int(time.time()) # datetime.timestamp(datetime.now())
self.JOB_URL = job_url
self.JOB_NAME = job_name
self.BUILD_NUMBER = build_number
def gen_sign(self):
# Splicing timestamp and secret
string_to_sign = '{}\n{}'.format(self.timestamp, self.feis_secret)
hmac_code = hmac.new(string_to_sign.encode("utf-8"), digestmod=hashlib.sha256).digest()
# Proceed with the result base64 Handle
sign = base64.b64encode(hmac_code).decode('utf-8')
return sign
def feis_post(self):
method = 'post'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3775.400 QQBrowser/10.6.4209.400',
'Content-Type': 'application/json'
}
json = {
"timestamp": self.timestamp,
"sign": self.gen_sign(),
"msg_type": "interactive",
"card": {
"config": {
"wide_screen_mode": True,
"enable_forward": True
},
"elements": [{
"tag": "div",
"text": {
"content": " Project name :" + JOB_NAME + "\n Build number : The first " + BUILD_NUMBER + " Time to build \n The elapsed time :" + self.currenttime,
"tag": "lark_md"
}
}, {
"actions": [{
"tag": "button",
"text": {
"content": " Check the report ",
"tag": "lark_md"
},
"url": JOB_URL,
"type": "default",
"value": {}
}],
"tag": "action"
}],
"header": {
"title": {
"content": JOB_NAME + " Build reports ",
"tag": "plain_text"
}
}
}
}
res = requests.request(method=method, url=self.feis_webhook, headers=headers, json=json)
print(res, "=======>>", res.json())
if __name__ == "__main__":
feis_webhook = r"https://open.feishu.cn/open-apis/bot/v2/hook/"
feis_secret = "YPkEsfe"
JOB_URL = sys.argv[1]
JOB_NAME = sys.argv[2]
BUILD_NUMBER = sys.argv[3]
# JOB_URL = JOB_NAME = BUILD_NUMBER = "123"
t = JenkinsInfo(feis_webhook, feis_secret, JOB_URL, JOB_NAME, BUILD_NUMBER)
t.feis_post()
3、Jenkins Add configuration to the project
In the build in the configuration Add a line of command
python3 /usr/local/jenkinsInfo/feishutongzhi.py $JOB_URL $JOB_NAME $BUILD_NUMBER
4、 verification
Click on “ Check the report ” You can jump to Jenkins
quote :
Jenkins+ Flying Book Robot sends notification _Song_Estelle The blog of -CSDN Blog _ The flying Book Robot sends a message to the user
https://blog.csdn.net/weixin_43484014/article/details/121950558Custom robot guide - Client documentation - Developing documents - Flying book open platform
https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjNjenkins Continuous integration of flybook sending report notification - Test Xiaobai - Blog Garden
https://www.cnblogs.com/spl-/p/14866221.htmlgitlab、jenkins + webhook Do the message notification of the code merge manager - BraveDu
http://www.bravedu.com/archives/204/
边栏推荐
- Yolov5 bird detection
- C # use objects comparer to compare objects
- 微擎系统在生产运行异常
- 私有云盘搭建
- Upgrade single instance Mongo to replica set
- 剑指offer 矩阵中的路径
- 重定向与请求转发
- 单实例Mongo升级为副本集
- Next time, the interviewer will ask about the design of high concurrency system and directly dump this article to him
- be based on. Net dynamic compilation technology to realize arbitrary code execution
猜你喜欢
JWT(JSON Web Token)的基础使用
提交时显示找不到匹配的主机密钥类型。
This free code snippet manager is open source!
CyclicBarrier
MySQL data specifies the field name and field remarks of the data table through SQL query
opencv之图片处理看这一篇就够了(一)
pytorch 目标检测数据增强cutmix和mixup混合
【 YOLOv5实现口罩和人脸检测】
Input text to automatically generate images, it's so fun!
Mongodb亿级别数据操作
随机推荐
常见网络厂商Mib库文件
Serialization concept learning
整数的分划问题
Introduction to pytoch target classification competition
YOLO系列目标检测数据集大全
Mongo排序超出最大内存错误
pytorch 目标检测竞赛(一)数据分析
Realization of ADC function based on stm32f030
pytorch mmdetection2.0安装训练测试(coco训练集)
c语言-链表二叉树-创建-遍历-求高度等复试常见问题
全局异常统一处理
Input text to automatically generate images, it's so fun!
重定向与请求转发
C language - linked list creation - merge - delete and other common retest operations
Selnium get JS content
Mysql千万级别水平分表优化
Yolov5 realizes smoking behavior detection
pytorch 目标检测数据增强cutmix和mixup混合
YOLOv5飞鸟检测
Firewall port forwarding