Commit e7eff1d2 authored by 徐晗's avatar 徐晗

first

parents
Pipeline #86666 failed with stages
in 0 seconds
import os
import sys
import pexpect
import requests
enviorments = ["debug", "intranettest", "outnettest", "preonline", "release"]
jiagu_username = "tiantianquwen@qq.com"
jiagu_psd = "tiantianquwen2018"
keyAlias = "kAlias-TUIA-312214"
keyPassword = "kPwd-TUIA-756658"
storePassword = "store-TUIA-201103"
jiagu_path = "./360jiagu/"
path = "./"
download_path = "/Library/WebServer/Documents/download/"
test_upload_url = "http://10.254.221.103:3344/apk/upload"
prod_upload_url = "http://10.254.71.106:3344/apk/upload"
def get_arg(arg_dict, key, default_value):
if key not in arg_dict:
return default_value
return arg_dict[key]
if __name__ == '__main__':
argv = sys.argv
if len(argv) < 4:
print("param error!")
exit(-1)
environment = argv[1]
channel = argv[2]
apk_name = argv[3]
if len(apk_name) == len(".apk"):
apk_name = environment + "-" + channel + ".apk"
arg_dict = {}
if len(argv) > 6:
for arg in argv:
if "=" not in arg:
continue
split = arg.split("=")
arg_dict[split[0]] = split[1]
# if environment not in enviorments:
# print(environment + " not valid!\n")
# exit(-1)
command = "cd " + path + "\n gradle clean assemble" + \
environment.capitalize() + " -PCHANNEL_CODE=" + channel
# print("开始打包...........\n")
# os.system(command)
# print("打包完成...........\n")
command = "find " + path + "app/build/outputs -name '*.apk' | grep tuia-android-news"
apk_path = str(os.popen(command).read()).replace("\n", "")
if len(apk_path) == 0:
print("package error!\n")
exit(-1)
is_upload = get_arg(arg_dict, "upload", "no")
if is_upload == "yes":
# 加固登录
command = "sudo java -jar " + jiagu_path + \
"/jiagu.jar -login " + jiagu_username + " " + jiagu_psd
os.system(command)
# 加固
command = "sudo java -jar " + jiagu_path + \
"/jiagu.jar -jiagu " + apk_path + " " + path
os.system(command)
command = "find " + path + " -name '*.apk' | grep jiagu"
apk_path = str(os.popen(command).read()).replace("\n", "")
if len(apk_name) == 0:
print("can not find apk\n")
exit(-1)
jkl_path = path + "/app/funNewsKey.jks"
command = "jarsigner -digestalg SHA1 -sigalg SHA1withRSA -verbose -keystore " + jkl_path + \
" -signedjar " + path + "/" + "jiagu.apk" + \
" " + apk_path + " " + keyAlias + "\n"
child = pexpect.spawn(command)
child.expect(".*")
child.sendline(storePassword)
child.expect(".*")
child.sendline(keyPassword)
child.expect(pexpect.EOF)
apk_path = path + "jiagu.apk"
# 上传至oss
version = get_arg(arg_dict, "version", "normal")
force_upload = get_arg(arg_dict, "force", "no")
oss_dir = "download/" + version + "/" + channel
data = {'enctype': 'multipart/form-data',
'dir': oss_dir,'fileName':apk_name, 'force': force_upload == "yes"}
files = {'file': open(apk_path, 'rb')}
if environment == 'release' or environment == 'Release':
url = prod_upload_url
else:
url = test_upload_url
response = requests.post(url, data=data, files=files)
download_url = response.text
if "http" in download_url:
success = True
else:
success = False
# 返回下载链接
os.system("echo " + response.text)
# 将文件放到下载服务器下
command = "sudo cp " + apk_path + " " + download_path + apk_name
os.system(command)
os.system("echo http://172.16.71.249/download/" + apk_name)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment