forked from vrabaud/buildfarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_jenkins_devel
executable file
·78 lines (64 loc) · 2.49 KB
/
create_jenkins_devel
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import sys
import jenkins
import urllib
import yaml
import subprocess
import optparse
from rospkg import environment
from run_jenkins_vcs import *
ubuntu_distro = {'fuerte': ['precise'],
'groovy': ['precise']}
arch = ['amd64', 'i386']
def call(command, envir=None):
print command
helper = subprocess.Popen(command.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True, env=envir)
res, err = helper.communicate()
print str(res)
print str(err)
if helper.returncode != 0:
print "Failed to execute command '%s'"%command
return res
# Schedule all devel jobs on Jenkins
def main():
parser = optparse.OptionParser()
parser.add_option("--delete", action="store_true", default=False)
(options, args) = parser.parse_args()
if len(args) != 1:
print "Usage: %s ros_distro"%(sys.argv[0])
sys.exit(0)
ros_distro = args[0]
# create jenkins instance
with open(os.path.join(environment.get_ros_home(), 'catkin-debs', 'server.yaml')) as f:
info = yaml.load(f)
jenkins_instance = jenkins.Jenkins('http://jenkins.willowgarage.com:8080/', info['username'], info['password'])
# parse the devel distro file
print "Parsing devel yaml file for %s"%ros_distro
f = urllib.urlopen('https://raw.github.com/ros/rosdistro/master/releases/%s-devel.yaml'%ros_distro)
devel = yaml.load(f.read())['repositories']
# create all jobs
devel_jobs = []
for s, conf in devel.iteritems():
for u in ubuntu_distro[ros_distro]:
for a in arch:
if conf['type'] == 'svn':
conf['version'] = ''
if not conf['version']:
conf['version'] = ''
print "----"
job_name = run_jenkins_vcs(jenkins_instance, u, a, ros_distro+'-'+s, '[email protected]',
conf['type'], conf['url'], conf['version'],
'devel', [ros_distro, s], info['username'])
devel_jobs.append(job_name)
# delete old jobs
if options.delete:
remove = []
current_jobs = [j['name'] for j in jenkins_instance.get_jobs()]
for c in current_jobs:
if 'devel-%s'%ros_distro in c and not c in devel_jobs:
remove.append(c)
for r in remove:
jenkins_instance.delete_job(r)
print "Deleted old job %s"%r
if __name__ == "__main__":
main()