This repository was archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.py
45 lines (36 loc) · 1.34 KB
/
main.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from workflow import Workflow
from jenkins.jenkins_interface import JenkinsInterface, NoJobsFound
def main(wf):
command = wf.args[0]
query = wf.args[1] if len(wf.args) > 1 else None
interface = JenkinsInterface(wf)
options = {
'set_url': interface.set_jenkins_url,
'login': interface.set_login,
'clear_login': interface.clear_login,
'failing': interface.get_failed_jobs,
'building': interface.get_building_jobs,
'all': interface.get_all_jobs
}
try:
jobs = options[command](query)
if not query:
wf.add_item("Open Jenkins",
arg=interface.get_jenkins_url(),
valid=True)
for job in jobs:
wf.add_item(title=job.name,
subtitle=job.description,
modifier_subtitles={
'ctrl': 'Trigger a build, and open'
},
arg=job.url,
valid=True,
icon=job.image)
except NoJobsFound:
wf.logger.debug("Could not find any jobs for instance: %s",
wf.settings['jenkins_url'])
wf.add_item("Error: No jobs found")
wf.send_feedback()
if __name__ == '__main__': # pragma: no cover
print Workflow().run(main)