您的位置:首页 > 产品设计 > UI/UE

Get Jenkins job build queue length

2015-12-28 16:51 295 查看
JenkinsAPIdoesn’tprovidethejobbuildqueuelength.Hence,itseemswehavetoparsethehtmltogetthejobbuildqueuelength

JenkinsAPI没有提供jobbuild队列长度,所以貌似只能用解析Html的方法取之。

Python:

fromBeautifulSoapimportBeautifulSoap
importrequests

JENKINS_JOB_URL='http://jenkins_url/job/%s'

defget_job_queue_length(job_name):

r=requests.get(JENKINS_JOB_URL%job_name)
soup=BeautifulSoup(r.text)
queue_item=soup.findAll(attrs={'class':'build-rowbuild-pendingtransitivesingle-line'})
length=len(queue_item)
returnlength



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: