#! /usr/bin/env python3 # -*- coding:UTF-8 -*-(添加) import sys import requests import json 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 + "{buildPlatform} {buildType} 包打好了\n" titleback = appName + "—" + buildPlatform + "—" + buildType + "—" + "包打好了\n" description = "build号: " + buildNum + "\n" + "分支: " + lcbBranch + "\n" + "启动用户: " + buildUser out_url = 'https://party.19920919.xyz:49101/download/' + download_url inner_url = 'http://172.23.30.2/download/' + download_url ios_install_url = 'itms-services://?action=download-manifest&url=' image_url = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" + inner_url 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": ios_install_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": ios_install_url + out_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": jobURL, "action_id": "button-action" } }, { "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" } } ] } response = requests.post( "https://hooks.slack.com/services/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", data=json.dumps(valueas), headers=headers) print(response.text) print(buildInfo)