Merge lp:~shadowrobot/sr-build-tools/feature-releasejobs into lp:sr-build-tools

Proposed by markpitchless
Status: Merged
Merged at revision: 117
Proposed branch: lp:~shadowrobot/sr-build-tools/feature-releasejobs
Merge into: lp:sr-build-tools
Diff against target: 208 lines (+93/-17)
1 file modified
bin/sr-jenkins-jobs (+93/-17)
To merge this branch: bzr merge lp:~shadowrobot/sr-build-tools/feature-releasejobs
Reviewer Review Type Date Requested Status
Ugo Approve
Review via email: mp+122067@code.launchpad.net

Description of the change

Add a add-release command to generate release jobs from a rosinstall file. e.g.

 bin/sr-jenkins-jobs -j jenkins:8080 add-release --prefix=test- --ros=electric data/shadow_robot-release.rosinstall

To post a comment you must log in.
Revision history for this message
markpitchless (markpitchless) wrote :
Revision history for this message
Ugo (ugocupcic) wrote :

Seems to be correct. Merging.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/sr-jenkins-jobs'
2--- bin/sr-jenkins-jobs 2012-06-01 15:37:25 +0000
3+++ bin/sr-jenkins-jobs 2012-08-30 13:36:19 +0000
4@@ -37,6 +37,7 @@
5 self.schedule = ""
6 self.description = ""
7 self.command = ""
8+ self.publish_junit = False
9 if color:
10 # jenkins module returns 'disabled' as a color, otherwise the jobs
11 # current status color. grey=new job, blue, red etc
12@@ -53,26 +54,47 @@
13
14 def as_xml(self):
15 """Generate the XML for this job"""
16+ var = self.__dict__
17+ var['labels'] = escape(self.labels)
18+ var['disabled'] = 'True' if self.disabled else 'False'
19 xml = """
20 <project>
21 <actions/>
22 <description>%(description)s</description>
23 <keepDependencies>false</keepDependencies>
24 <properties/>
25- <scm class="hudson.plugins.bazaar.BazaarSCM">
26- <source>%(bzr_source)s</source>
27- <clean>true</clean>
28- <checkout>false</checkout>
29- </scm>
30+ """
31+
32+ if var['bzr_source']:
33+ xml += """
34+ <scm class="hudson.plugins.bazaar.BazaarSCM">
35+ <source>%(bzr_source)s</source>
36+ <clean>true</clean>
37+ <checkout>false</checkout>
38+ </scm>
39+ """
40+ else:
41+ xml += """
42+ <scm class="hudson.scm.NullSCM"/>
43+ """
44+
45+ xml += """
46 <assignedNode>%(labels)s</assignedNode>
47 <canRoam>false</canRoam>
48 <disabled>%(disabled)s</disabled>
49 <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
50 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
51 <triggers class="vector">
52+ """
53+
54+ if var['schedule']:
55+ xml += """
56 <hudson.triggers.SCMTrigger>
57 <spec>%(schedule)s</spec>
58 </hudson.triggers.SCMTrigger>
59+ """
60+
61+ xml += """
62 </triggers>
63 <concurrentBuild>false</concurrentBuild>
64 <builders>
65@@ -81,19 +103,23 @@
66 </hudson.tasks.Shell>
67 </builders>
68 <publishers>
69+ """
70+
71+ if var['publish_junit']:
72+ xml += """
73 <hudson.tasks.junit.JUnitResultArchiver>
74 <testResults>test_results/_hudson/*.xml</testResults>
75 <keepLongStdio>false</keepLongStdio>
76 <testDataPublishers/>
77 </hudson.tasks.junit.JUnitResultArchiver>
78+ """
79+
80+ xml += """
81 <org.jenkinsci.plugins.emotional__jenkins.EmotionalJenkinsPublisher/>
82 </publishers>
83 <buildWrappers/>
84 </project>
85 """
86- var = self.__dict__
87- var['labels'] = escape(self.labels)
88- var['disabled'] = 'True' if self.disabled else 'False'
89 return xml % var
90
91 class CmdError(Exception):
92@@ -199,7 +225,7 @@
93 grp.add_option('--distros', '--dist', action='append',
94 help='Distro(s) to create jobs for. Give multiple times for '
95 "multiple distros. e.g. 'ubuntu'.")
96- grp.add_option('--dist-releases', '--release', action='append',
97+ grp.add_option('--dist-releases', '--release', '--rel', action='append',
98 help='Distro release(s) to create jobs for. Give multiple times for '
99 "multiple releases. e.g. 'lucid'")
100 grp.add_option('--architectures', action='append',
101@@ -212,6 +238,17 @@
102 help='ROS install file to use to create workspace for job to run in.'
103 ' Value is file name that must exist in sr-build-tools/data')
104 optp.add_option_group(grp)
105+
106+ grp = optparse.OptionGroup(optp, "Command: add-release OPTIONS FILE",
107+ strip_indent(self.cmd_add_release.__doc__))
108+ grp.add_option('--release-slave', default='slave-dev',
109+ help='Name of slave used for release builds. Default=%default')
110+ grp.add_option('--user-mirror', default='http://packages.shadow.local/ubuntu',
111+ help='Url for the deb repo we are building for. Default=%default')
112+ grp.add_option('--repo-upload',
113+ default='packages@packages.shadow.local:/srv/packages/ubuntu',
114+ help="SSH login and path for uploading devs. slave is assumed to already have a key set that allows access. Default=%default")
115+ optp.add_option_group(grp)
116
117 self.opts, self.cmd_args = optp.parse_args()
118
119@@ -252,6 +289,7 @@
120 elif self.cmd in ['disable', 'off']: return self.cmd_disable()
121 elif self.cmd in ['build', 'run']: return self.cmd_build()
122 elif self.cmd in ['add-rosinstall']: return self.cmd_add_rosinstall()
123+ elif self.cmd in ['add-release']: return self.cmd_add_release()
124 else:
125 self.log.error("Unknown command %s" % self.cmd)
126 optp.print_usage()
127@@ -321,14 +359,7 @@
128 for job in self._get_arg_jobs():
129 self.build_job(job)
130
131- def cmd_add_rosinstall(self):
132- """
133- Generate jobs from a rosinstall file. For each stack listed add a job
134- per package, searching the bzr uri for the list of packages.
135- """
136- if len(self.cmd_args) < 1: raise CmdError("No rosinstall file")
137- f = self.cmd_args[0]
138-
139+ def load_yaml(self,f):
140 data = None
141 try:
142 data = yaml.load(open(f))
143@@ -338,6 +369,16 @@
144 raise CmdError("Failed to parse %s : %s" % (f, e))
145 except:
146 raise
147+ return data
148+
149+ def cmd_add_rosinstall(self):
150+ """
151+ Generate jobs from a rosinstall file. For each stack listed add a job
152+ per package, searching the bzr uri for the list of packages.
153+ """
154+ if len(self.cmd_args) < 1: raise CmdError("No rosinstall file")
155+ f = self.cmd_args[0]
156+ data = self.load_yaml(f)
157
158 # Use info to turn this into a set of add-packages calls
159 if not self.opts.workspace_install:
160@@ -353,6 +394,31 @@
161 )
162 return 0
163
164+ def cmd_add_release(self):
165+ """Generate release jobs from a rosinstall file. Needs --ros-versions
166+ option above."""
167+ if len(self.cmd_args) < 1: raise CmdError("No rosinstall file")
168+ f = self.cmd_args[0]
169+ data = self.load_yaml(f)
170+
171+ if not self.opts.workspace_install:
172+ self.opts.workspace_install = os.path.basename(f)
173+
174+ for inst in data:
175+ if not 'bzr' in inst:
176+ self.log.error("Can't handle non bzr source: %s " % inst.keys[0])
177+ continue
178+ for rosv in self.opts.ros_versions:
179+ self.add_release_stack(
180+ stack = inst['bzr']['local-name'],
181+ rosv = rosv,
182+ ws = self.opts.workspace_install,
183+ user_mirror = self.opts.user_mirror,
184+ repo_upload = self.opts.repo_upload
185+ )
186+ return 0
187+
188+
189 def add_packages(self, stack=None, branch=None, packages=None):
190 """Generates a set of shadow build jobs for the given options and
191 package list. Will generate jobs for all the combinations of options.
192@@ -434,6 +500,16 @@
193 job.labels = " && ".join((args['dist'], args['rel'], args['arch']))
194 job.schedule = self.opts.schedule
195 job.command = "/opt/shadow/sr-build-tools/bin/sr-jenkins-build %(rosv)s %(ws)s %(pkg)s" % args
196+ job.publish_junit = True
197+ self.add_job(job)
198+
199+ def add_release_stack(self, **args):
200+ """Add a release job for the given config"""
201+ job_name = "release-%(rosv)s-%(stack)s" % args
202+ job = SrJenkinsJob(job_name)
203+ job.labels = self.opts.release_slave
204+ job.command = "/opt/shadow/sr-build-tools/bin/sr-jenkins-release %(rosv)s %(ws)s %(stack)s \"%(user_mirror)s\" \"%(repo_upload)s\"" % args
205+ job.publish_junit = False
206 self.add_job(job)
207
208 def add_job(self, job):

Subscribers

People subscribed via source and target branches

to all changes: