VSTS DevOps practice automated deployment, packaged APK and uploaded to Dandelion or fir, how to achieve it?
First, let’s write the Python script first:
Script source: https://blog.csdn.net/caption_deng/article/details/78681541
import requests
import sys
def< /span> uploadFile():
# Get the parameters passed by the operation
_upload_url = sys.argv[1]
_api_key = sys.argv[ 2]
_apk_path = sys.argv[3]
_description = sys.argv[4]
# Upload apk
try:
file = {'file': open(_apk_path, 'rb')}
param = {'_api_key< span style="color: #800000">': _api_key, 'updateDescription ':
_description}
req=requests.post(url= _upload_url,files=file,data=param,verify=False)
print< span style="color: #000000">(req.status_code)
except Exception as e:
print("upload:" + e)
if __name__ == '__main__':
uploadFile()
After saving the script, upload it to the source code, and then in VSTS Configure the script.
Before this, python also needs to install the requests library, so before the “upload to dandelion” script, you need to add the “initialize Python” script to install the resquests library.
So you can upload it to Dandelion.
p>
If you need to upload to fir, you can replace the upload script. The requests library also needs to be installed.
Script source: https://www.jianshu.com/p/0ec4c4e132e7
import requests
try:
print("Upload apk")
apk_path = 'F:/PythonDemo/Demo/app-release.apk'
file = {'file': open(apk_path, 'rb ')}
param = {"key": ' 61a53809c7b58d8b68e537c3d4831b01325b1f0b .apk', " token": 'you Own token', "x:name": 'Test', "x:version": '1.0', "x:build": '1', "x:changelog": 'No updates yet'}
req = requests.post('https://upload.qbox.me', files=file, data=param, verify=False)
print 'success:' + req.content
except Exception as e:
print'error:' + e
< /p>
import requests
importsys
def uploadFile():
# Get the parameters passed by the operation
_upload_url = sys.argv[1]
_api_key = sys.argv[2]
_apk_path = sys.argv[3]
_description = sys.argv[4]< br /> # upload apk
try:
file = {'< span style="color: #800000">file': open(_apk_path, ' span>rb')}
param span>= {'_api_key' span>: _api_key, 'updateDescription'< /span>:
_description}
req=requests.post(url=_upload_url,files=file,data=param,verify=< span style="color: #000000">False)
print(req. status_code)
except Exception as e:
< span style="color: #0000ff">print("upload:< span style="color: #800000">" + e)
if< /span> __name__ == '__main__':
uploadFile()
import requests
try:
print("Upload apk")
apk_path = '< span style="color: #800000">F:/PythonDemo/Demo/app-release.apk'
file = {'file': open(apk_path , 'rb') }
param = {"key ": '61a53809c7b58d8b68e537c3d4831b01325b1f0b.apk', "token": 'your own token', "x:name": 'Test', "x:version": '1.0', "x:build": '1', "x:changelog": 'No updates yet'}
req = requests.post('https://upload.qbox.me', files =file, data=param, verify=False)
print 'success:' + req.content
except span> Exception as e:
print'error:' + e