summaryrefslogtreecommitdiff
path: root/jenkinstool
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2012-08-25 16:09:41 +0100
committerLars Wirzenius <liw@liw.fi>2012-08-25 16:09:41 +0100
commitde5b6d94f914a9f373f70f8aa52a1ca1de08c9b9 (patch)
tree684d658df4ab1ebe875ba006a11d7c1fb993e4e3 /jenkinstool
parent8a00fdeabd8deded4b852892a8cd205597b2e137 (diff)
downloadjenkinstool-de5b6d94f914a9f373f70f8aa52a1ca1de08c9b9.tar.gz
Add build dependency support
If foo needs bar to build, but yoyo does not, and bar changes, then there's no point in running the pipeline for yoyo.
Diffstat (limited to 'jenkinstool')
-rwxr-xr-xjenkinstool62
1 files changed, 50 insertions, 12 deletions
diff --git a/jenkinstool b/jenkinstool
index fba6ce3..74e06b5 100755
--- a/jenkinstool
+++ b/jenkinstool
@@ -130,35 +130,73 @@ class JobGenerator(object):
'''
- trigger = self.trigger_everything_job(config)
- jobs = [trigger]
+ # Create a job to trigger all other jobs.
+ a1trigger = self.trigger_everything_job(config)
+ jobs = [a1trigger]
+ # Setup reprepro on Jenkins host.
reprepro = self.reprepro_setup_job(config)
+ jobs[-1].add_build_trigger(reprepro.job_id())
jobs.append(reprepro)
-
+
+ # Create or update pbuilder tarballs.
for host in config['hosts']:
jc = self.pbuilder_create_job(host)
+ jobs[-1].add_build_trigger(jc.job_id())
jobs.append(jc)
+
+ # Trigger all project pipelines.
+ trigger = self.trigger_projects_job(config)
+ jobs[-1].add_build_trigger(trigger.job_id())
+ jobs.append(trigger)
+ # Create a pipeline for each project. Every job in the pipeline
+ # triggers the next job. The first job is not triggered yet,
+ # we set up that later.
+ pipelines = {}
for project in config['projects']:
+ prev = None
for jc in self.generate_project(config, project):
+ if prev:
+ prev.add_build_trigger(jc.job_id())
+ pipelines[project['name']].append(jc)
+ else:
+ pipelines[project['name']] = [jc]
+ prev = jc
jobs.append(jc)
- prev = jobs[0]
- for jc in jobs[1:]:
- prev.add_build_trigger(jc.job_id())
- prev = jc
-
- for jc in jobs:
- yield jc.job_id(), jc.tostring()
+ # Add triggers for each project pipeline: the last job of each of
+ # its build dependencies triggers the first job in the project's
+ # pipeline. Projects without build dependencies are triggered by
+ # the trigger-everything job.
+ for project in config['projects']:
+ first = pipelines[project['name']][0]
+ deps = project.get('build-depends', [])
+ if deps:
+ for dep in deps:
+ pipeline = pipelines[dep]
+ pipeline[-1].add_build_trigger(first.job_id())
+ else:
+ trigger.add_build_trigger(first.job_id())
+
+ return [(jc.job_id(), jc.tostring()) for jc in jobs]
def trigger_everything_job(self, config):
'''Create job that triggers every other job.'''
host = config['hosts'][0]
- project = {'name': 'a1trigger'}
+ project = {'name': 'a1_trigger'}
+ jc = self.create_job_config(host, project, 'trigger')
+ jc.set_description('A1 Trigger All Jobs')
+ return jc
+
+ def trigger_projects_job(self, config):
+ '''Create job that triggers pipelines for projects.'''
+
+ host = config['hosts'][0]
+ project = {'name': 'a2_trigger_projects'}
jc = self.create_job_config(host, project, 'trigger')
- jc.set_description('A1 Job Trigger')
+ jc.set_description('A2 Project Trigger')
return jc
def reprepro_setup_job(self, config):