-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwatchjob
More file actions
executable file
·39 lines (31 loc) · 939 Bytes
/
watchjob
File metadata and controls
executable file
·39 lines (31 loc) · 939 Bytes
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
#!/usr/bin/python
import requests
import subprocess
import sys
import time
from requests.packages import urllib3
urllib3.disable_warnings()
try:
jenkins_url = sys.argv[1]
except IndexError:
print "Usage: watchjob [jenkins_url]"
sys.exit()
jenkins_url += "api/json"
job_info = requests.get(jenkins_url, verify=False).json()
latest_build = job_info['builds'][0]['url'] + 'api/json'
output = {}
while 'result' not in output or output['result'] is None:
try:
output = requests.get(latest_build, verify=False).json()
if 'result' not in output or output['result'] is None:
print 'RUNNING'
time.sleep(1)
except KeyboardInterrupt:
sys.exit()
print output['result']
while True:
try:
subprocess.call('say {process} is complete 2>/dev/null'.format(process=job_info['displayName']), shell=True)
time.sleep(15)
except KeyboardInterrupt:
sys.exit()