-
Notifications
You must be signed in to change notification settings - Fork 0
/
infoLatestBuild.py
30 lines (22 loc) · 993 Bytes
/
infoLatestBuild.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from jenkinsapi.jenkins import Jenkins
def get_server_instance():
jenkins_url = 'http://localhost:8080'
server = Jenkins(jenkins_url, username='sgn', password='toor')
return server
def get_job_details():
# Refer Example #1 for definition of function 'get_server_instance'
server = get_server_instance()
for j in server.get_jobs():
job_instance = server.get_job(j[0])
print('Job Name:%s' % (job_instance.name))
print('Job Description:%s' % (job_instance.get_description()))
print('Is Job running:%s' % (job_instance.is_running()))
print('Is Job enabled:%s' % (job_instance.is_enabled()))
def getSCMInfoFromLatestBuild(url, jobName, username=None, password=None):
J = Jenkins(url, username, password)
job = J[jobName]
lgb = job.get_last_completed_build()
lgb.get_console()
return lgb.get_console()
# get_job_details()
print(getSCMInfoFromLatestBuild('http://localhost:8080', 'todo-api', 'sgn', 'toor'))