VSTS DevOps实践自动化部署,打包APK并上传到蒲公英或者fir
VSTS DevOps实践自动化部署,打包APK并上传到蒲公英或者fir,怎么实现呢?
首先,我们先写好Python脚本:
脚本来源:https://blog.csdn.net/caption_deng/article/details/78681541
import requests import sys def uploadFile(): # 获取运行传递过来的参数 _upload_url = sys.argv[1] _api_key = sys.argv[2] _apk_path = sys.argv[3] _description = sys.argv[4] # 上传apk try: file = {'file': open(_apk_path, 'rb')} param = {'_api_key': _api_key, 'updateDescription': _description} req=requests.post(url=_upload_url,files=file,data=param,verify=False) print(req.status_code) except Exception as e: print("upload:" + e) if __name__ == '__main__': uploadFile()
保存好脚本后,上传到源代码中,然后在VSTS中配置好脚本。
在这之前python还需要安装requests库,所以在“上传到蒲公英”这个脚本前面,需要加入"初始化Python"脚本来安装resquests库。
这样就可以上传到蒲公英啦。
如果需要上传到fir,可以替换掉上传脚本。同样需要安装requests库。
脚本来源:https://www.jianshu.com/p/0ec4c4e132e7
import requests
try:
print("上传apk")
apk_path = 'F:/PythonDemo/Demo/app-release.apk'
file = {'file': open(apk_path, 'rb')}
param = {"key": '61a53809c7b58d8b68e537c3d4831b01325b1f0b.apk', "token": '你自己的token', "x:name": '测试', "x:version": '1.0', "x:build": '1', "x:changelog": '暂无更新'}
req = requests.post('https://upload.qbox.me', files=file, data=param, verify=False)
print 'success:' + req.content
except Exception as e:
print'error:' + e