Python sample code of hudson remote api, my first Python hello world
2010-07-21 09:44
627 查看
refer http://wiki.hudson-ci.org/display/HUDSON/Remote+access+API for more about hudson remote api
#!/usr/bin/env python
# this
script is only demo purpose which is designed to get properties of job, queue, like
# nextBuildNumber. But note the logistics might not be correct
import
urllib2
#call api of job 'git_plugin_test'
url="http://localhost:9001/job/git_plugin_test/api/python?depth=0"
response=urllib2.urlopen(url)
build_dict=eval(response.read())
#call api of job 'queue' of hudson (global but not specific for
one job)
url="http://localhost:9001/queue/api/python?depth=0"
response=urllib2.urlopen(url)
queue_dict=eval(response.read())
print ''*40,'build dict',''*40
#print properties of job
for
eachKey in build_dict:
print eachKey,build_dict[eachKey]
print ''*40,'queue dict',''*40
#look through items in queue and can be extended to forecast the job build
#number in for
one item in queue
for
index in range(1,len(queue_dict['items'])):
print ''*40,'queue hash',''*40
qi_action=queue_dict['items'][index]['actions']
list_para=qi_action[0]['parameters']
for
index1 in range(0,len(list_para)):
print list_para[index1]
if
list_para[index1]['name'] == 'SLEEP_TIME' and list_para[index1]['value'] == '62':
print "OK"
#only valid when no more than one build found in queue
if
build_dict['inQueue']:
build_number=int
(build_dict['nextBuildNumber']) + 1
else
:
build_number=int
(build_dict['nextBuildNumber'])
print "Hudson Build URL:"
,build_dict['url']+str(build_number)
print "Current build tree:"
+build_dict['builds'][0]['url']
相关文章推荐
- 【Hello Python World】Class Notes of Week 2
- Byte-of-python笔记代码1:helloworld.py
- 【Hello Python World】Class Notes of Week 5
- My First Python code for learnning English.
- 写一个程序,用于分析一个字符串中各个单词出现的频率,并将单词和它出现的频率输出显示。(单词之间用空格隔开,如“Hello World My First Unit Test”)
- My First HelloWorld Module for Apache~
- (1)写一个程序,用于分析一个字符串中各个单词出现的频率,并将单词和它出现的频率输出显示。(单词之间用空格隔开,如“Hello World My First Unit Test”); (2)编写单元测试进行测试; (3)用ElcEmma查看代码覆盖率,要求覆盖率达到100%。
- My First Hello World in PHP
- 写一个程序,用于分析一个字符串中各个单词出现的频率,并将单词和它出现的频率输出显示。(单词之间用空格隔开,如“Hello World My First Unit Test”)
- 写一个程序,用于分析一个字符串中各个单词出现的频率,并将单词和它出现的频率输出显示。(单词之间用空格隔开,如“Hello World My First Unit Test”);
- 写一个程序,用于分析一个字符串中各个单词出现的频率,并将单词和它出现的频率输出显示。(单词之间用空格隔开,如“Hello World My First Unit Test”);
- 【Hello Python World】Class Notes of Week 4
- My First HelloWorld-----------让圆角来美化csdn Blog
- 写一个程序,用于分析一个字符串中各个单词出现的频率,并将单词和它出现的频率输出显示。(单词之间用空格隔开,如“Hello World My First Unit Test”)
- 写一个程序,用于分析一个字符串中各个单词出现的频率,并将单词和它出现的频率输出显示。(单词之间用空格隔开,如“Hello World My First Unit Test”)
- The Source Code Of My World(我的世界之源代码)中的经典语句
- First Demo of Xspider Mycode
- (转) Eclipse - Python - Installation of PyDev with a Python Hello World tutorial
- python 3.4.0 简单的print 'hello world',出错--SyntaxError: invalid syntax