1 Star 0 Fork 0

薛定谔的毛/report-upload

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
upload.py 1.24 KB
Copy Edit Raw Blame History
方便面调料 authored 2020-06-22 16:17 . fix report path
import os
import sys
import shutil
from flowci import domain, client
# inputs of plugin
ReportPath = os.path.join(domain.AgentJobDir, client.GetVar('REPORT_PATH'))
ReportName = client.GetVar('REPORT_NAME')
ReportContentType = client.GetVar('REPORT_CONTENT_TYPE')
EntryFile = client.GetVar('REPORT_ENTRY_FILE')
def checkContentType(t):
valid = {
domain.ContentTypeHtml: 1,
domain.ContentTypeJson: 1,
domain.ContentTypeXml: 1
}
return valid.get(t) is not None
def sendReport():
if not os.path.exists(ReportPath):
sys.exit("'{}' not existed".format(ReportPath))
if not checkContentType(ReportContentType):
sys.exit("Report content type not suported")
upload = ReportPath
isZipFile = "false"
if os.path.isdir(ReportPath):
zipFileName = os.path.basename(ReportPath)
upload = shutil.make_archive(zipFileName, 'zip', ReportPath)
isZipFile = "true"
print("zipped.")
api = client.Client()
status = api.sendJobReport(
path=upload,
name=ReportName,
zipped=isZipFile,
contentType=ReportContentType,
entryFile=EntryFile
)
print("{} report uploaded with status {}".format(ReportPath, status))
sendReport()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiongxiaoyu/report-upload.git
git@gitee.com:xiongxiaoyu/report-upload.git
xiongxiaoyu
report-upload
report-upload
master

Search

0d507c66 1850385 C8b1a773 1850385