前段时间和开发搭建了本地 fastdfs,我一直没用过,正好拿来试用一下

步骤

1、Jenkins+gradle 打包生成 apk 文件
2、apk 文件上传 fastdfs,获取链接
3、链接转二维码,再次上传 fastdfs,再次获取链接
4、钉钉机器人发送链接
Jenkins Execute shell
cd /home/chen/PycharmProjects/test3
cp /home/chen/.jenkins/workspace/Build_002_Android_2.0/app/build/outputs/apk/release/*.apk 1111.apk
python3 021_fastdfs.py

021_fastdfs.py
from fdfs_client.client import *
import requests
import json
import qrcode

client = Fdfs_client()
ret = client.upload_by_filename('/home/chen/PycharmProjects/test3/1111.apk')
a = ret['Remote file_id']
b = 'http://192.168.0.10:8888/'+a
print(b)

img = qrcode.make(b)
img.save("xx.png")
ret = client.upload_by_filename('/home/chen/PycharmProjects/test3/xx.png')
a = ret['Remote file_id']
b = 'http://192.168.0.10:8888/'+a
print(b)

dingdingurl = 'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
headers = {"Content-Type": "application/json;"}
payload = {
    "msgtype": "link",
    "link": {
        "text":"这个即将发布的新版本",
        "title": "2.0_apk",
        "picUrl": "",
        "messageUrl": b
    }
}
r = requests.post(dingdingurl, data=json.dumps(payload), headers=headers)
print(r.text)


↙↙↙阅读原文可查看相关链接,并与作者交流