持续集成 Jenkins 打包 Android,将 apk 二维码发送钉钉

Jacc · 2018年05月17日 · 1609 次阅读

前段时间和开发搭建了本地 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)

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册