代码拉取完成,页面将自动刷新
import jenkins
job_name = "ec-oneapp"
"""
"""
class Jenkins_Api:
def __init__(self, username='', password=''):
self._url = 'http://10.128.43.56:8080/'
self._username = username
self._password = password
self.get_server = jenkins.Jenkins(self._url) # username=self._username, password=self._password)
def get_version(self):
return self.get_server.get_version()
def get_jobs(self):
return self.get_server.get_jobs()
def get_jobs_count(self):
return self.get_server.jobs_count()
def get_job_config(self, job_name):
return self.get_server.get_job_config(job_name)
def create_job(self, job_name, config_xml):
return self.get_server.create_job(job_name, config_xml)
def copy_job(self, job_name, new_job_name):
return self.get_server.copy_job(job_name, new_job_name)
def delete_job(self, job_name):
return self.get_server.delete_job(job_name)
def build_job(self, job_name):
return self.get_server.build_job(job_name)
def get_job_info(self, job_name):
return self.get_server.get_job_info(job_name)
def get_job_number(self, job_name):
return self.get_server.get_job_info(job_name)['lastCompletedBuild']['number']
def get_build_info(self, job_name, number):
return self.get_server.get_build_info(job_name, number)
def get_views(self):
return self.get_server.get_views()
import jsonpath
api = Jenkins_Api()
number = api.get_job_number(job_name)
print("The last number is {}".format(number))
build = api.get_build_info(job_name, number)
branch = jsonpath.jsonpath(build, '$.actions..parameters')
author = jsonpath.jsonpath(build, '$.actions..userName')
buildinfo = {}
buildinfo["url"] = build['url']
buildinfo["author"] = author
for x in branch[0]:
buildinfo[x['name']] = x['value']
print(buildinfo)
# if build['url'] != "":
#
# print("...start to open url...")
#
# import webbrowser as web
#
# web.open(build['url'], new=0, autoraise=True) # new:0/1/2 0:同一浏览器窗口打开 1:打开浏览器新的窗口,2:打开浏览器窗口新的tab
# # #autoraise=True:窗口自动增长
# # web.open_new("")
# # web.open_new_tab("")
# else:
# print("no url found!")
build_url = build['url'] + r"artifact/Export/{}/Smart%20English.ipa".format(buildinfo['PARAM_ENVIRONMENT'])
print(build_url)
import requests
import json
rainbow="http://10.128.43.56:8181/products/E790FA8D-86C8-4C28-A2AD-86CD8792969F/builds"
r = requests.get(rainbow)
content = r.json()
result = content["builds"]
from operator import itemgetter
import time
for x in result:
x['uploaded_at']= time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(x['uploaded_at']))
print(json.dumps(result,indent=4))
with open ("/Users/anderson/Downloads/bridge.json","w+") as f:
f.write(json.dumps(result,indent=4))
url =result[0]["manifest_url"].replace("manifests","packages").replace("manifest.plist","package.ipa")
print(url)
print(result[0]["app_version"])
print(result[0]["branch"])
print(result[0]["configuration"])
print(result[0]["commit_number"])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。