gpt4 book ai didi

python - 我如何使用 python Jenkins API 获取特定日期之间的所有这些内部版本号?

转载 作者:太空宇宙 更新时间:2023-11-04 02:12:21 29 4
gpt4 key购买 nike

例如,我有一堆介于 22 和 23 之间的构建。我如何使用 python Jenkins API 获取特定日期之间的所有这些构建编号?

enter image description here

最佳答案

import jenkins
from datetime import datetime

jenkins_url=''
username=''
password=''
job_name=''

# Fill up your dates in below fields.
startDate = int(datetime(2018, 10, 20).strftime('%s'))
endDate = int(datetime(2018, 11, 25).strftime('%s'))



server = jenkins.Jenkins(jenkins_url,username,password)
job_info=server.get_job_info(job_name)

#get the number of finished builds of the job
total_builds=job_info['lastBuild']['number']


for build_number in range(1, total_builds):
# get build info for every build number.
build_info = server.get_build_info(job_name, build_number)
timestamp=build_info['timestamp']
timestamp=timestamp/1000 # The timestamp returned by Jenkins api is in miliseconds
build_date=datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
if (timestamp > startDate) & (timestamp < endDate):
print 'Build Time: '+str(build_date)

它对我有用。我希望它也适合你。谢谢:)

关于python - 我如何使用 python Jenkins API 获取特定日期之间的所有这些内部版本号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53441011/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com