#! /usr/bin/env python3 # -*- coding:UTF-8 -*-(添加) import sys import requests import json import subprocess import plistlib buildNum = sys.argv[1] changeLog = sys.argv[2] buildType = sys.argv[3] versionName = sys.argv[4] buildPlatform = sys.argv[5] buildInfo = sys.argv[6] lcbBranch = sys.argv[7] appName = sys.argv[8] download_url = sys.argv[9] buildUser = sys.argv[10] jobURL = sys.argv[11] headers = { 'Content-Type': 'application/json' } # image_url = "https://bj.bcebos.com/qr-code/23111014f49aeb5fa696.jpg" tips = "扫描二维码下载热乎的" + buildPlatform + "包吧,仅限办公区网络哦" title = appName + f"{buildPlatform} {buildType} 包打好了\n" titleback = appName + "—" + buildPlatform + "—" + buildType + "—" + "包打好了\n" description = "build号: " + buildNum + "\n" + "分支: " + lcbBranch + "\n" + "启动用户: " + buildUser out_base_url = 'https://party.19920919.xyz:49101/download/' inner_base_url = 'http://172.23.30.2/download/' inner_base_https_url = 'https://inner.19920919.xyz:8301/download/' out_url = out_base_url + download_url inner_url = inner_base_url + download_url ios_install_url = 'itms-services://?action=download-manifest&url=' image_url = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" + 'itms-services://?action=download-manifest%26url=' + inner_base_https_url + "plist/" + buildNum + "_inner.plist" def read_plist_file(file_path): with open(file_path, 'rb') as fp: plist_data = plistlib.load(fp) return plist_data def write_plist_file(file_path, data): with open(file_path, 'wb') as fp: plistlib.dump(data, fp) def configPlist(baseUrl, base): pl = read_plist_file("/Users/a1/ci/PartyStar.plist") url = baseUrl + download_url pl["items"][0]["assets"][0]["url"] = url plistPath = f"/Users/a1/Documents/build/plist/{buildNum}_{base}.plist" write_plist_file(plistPath, pl) # 如果appName = Party Star,则上传到plist, 否则上传到PartyGo/plist if appName == "Party Star": cmd = f"curl -X POST http://172.23.30.2:5000/upload -F 'file=@{plistPath}' -F 'destination=plist/'" else: cmd = f"curl -X POST http://172.23.30.2:5000/upload -F 'file=@{plistPath}' -F 'destination=PartyGo/plist/'" os.system(cmd) return baseUrl + f"plist/{buildNum}_{base}.plist" if buildPlatform == 'ios': valueas = { "blocks": [ { "type": "header", "text": { "type": "plain_text", "text": titleback + description, } }, { "type": "section", "text": { "type": "mrkdwn", "text": tips, }, "accessory": { "type": "image", "image_url": image_url, "alt_text": "cute cat" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "点击前往任务网页" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "打开网页", }, "value": "click_me_123", "url": f"{jobURL}", "action_id": "button-action" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "点击下载安装包(内网)" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "去下载", }, "value": "click_me_123", "url": f"https://inner.19920919.xyz:8301/index.html?path={buildNum}_inner.plist&inner=1", "action_id": "button-action" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "点击下载安装包(外网)" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "去下载", }, "value": "click_me_123", "url": f"https://party.19920919.xyz:49101/index.html?path={buildNum}_out.plist&inner=0", "action_id": "button-action" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "点击下载ipa(外网)" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "去下载", }, "value": "click_me_123", "url": f"{out_url}", "action_id": "button-action" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "点击下载ipa(内网)" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "去下载", }, "value": "click_me_123", "url": f"{inner_url}", "action_id": "button-action" } } ] } else: valueas = { "blocks": [ { "type": "header", "text": { "type": "plain_text", "text": titleback + description, } }, { "type": "section", "text": { "type": "mrkdwn", "text": tips, }, "accessory": { "type": "image", "image_url": image_url, "alt_text": "cute cat" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "点击下载安装包(内网)" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "去下载", }, "value": "click_me_123", "url": inner_url, "action_id": "button-action" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "点击下载安装包(外网)" }, "accessory": { "type": "button", "text": { "type": "plain_text", "text": "去下载", }, "value": "click_me_123", "url": out_url, "action_id": "button-action" } } ] } # print(valueas) # response = requests.post( # "https://hooks.slack.com/services/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", # data=json.dumps(valueas), headers=headers) # print(response) # print(buildInfo) v = json.dumps(valueas) # 拼接curl语句, 把v拼接到下面的字符串中 curl = f""" curl -X POST https://hooks.slack.com/services/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 \ -H "Content-Type: application/json" \ -d '{v}' """ print(curl) result = subprocess.run(curl, shell=True, capture_output=True, text=True) print(result.stdout) # if appName == "Party Star": configPlist(inner_base_url, "inner") configPlist(out_base_url, "out") # else: # configPlist(inner_base_url+"PartyGo/", "inner") # configPlist(out_base_url+"PartyGo/", "out")