From 53c41a0e5fcd883f140bb4426e31a18db7e8bb24 Mon Sep 17 00:00:00 2001 From: Sergey Kolekonov Date: Mon, 10 Feb 2014 14:36:57 +0400 Subject: [PATCH] Heavy Job Plugin support added This plugin allows you to define "weight" on each job, and making each job consume that many executors Change-Id: Iee49229b0d3c909f320caa9bd6c1ebb6bc37ddcb --- jenkins_jobs/modules/properties.py | 24 ++++++++++++++++++++++++ setup.py | 1 + tests/properties/fixtures/heavy-job.xml | 8 ++++++++ tests/properties/fixtures/heavy-job.yaml | 3 +++ 4 files changed, 36 insertions(+) create mode 100644 tests/properties/fixtures/heavy-job.xml create mode 100644 tests/properties/fixtures/heavy-job.yaml diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index db67a24e0..8b35fea31 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -489,6 +489,30 @@ def batch_tasks(parser, xml_parent, data): XML.SubElement(batch_task, 'script').text = task['script'] +def heavy_job(parser, xml_parent, data): + """yaml: heavy-job + This plugin allows you to define "weight" on each job, + and making each job consume that many executors + + Requires the Jenkins `Heavy Job Plugin. + `_ + + :arg int weight: Specify the total number of executors + that this job should occupy (defaults to 1) + + + Example: + + .. literalinclude:: /../../tests/properties/fixtures/heavy-job.yaml + + """ + heavyjob = XML.SubElement(xml_parent, + 'hudson.plugins.' + 'heavy__job.HeavyJobProperty') + XML.SubElement(heavyjob, 'weight').text = str( + data.get('weight', 1)) + + class Properties(jenkins_jobs.modules.base.Base): sequence = 20 diff --git a/setup.py b/setup.py index cb8a0ed81..5437784bf 100644 --- a/setup.py +++ b/setup.py @@ -85,6 +85,7 @@ setuptools.setup( 'build-blocker=jenkins_jobs.modules.properties:build_blocker', 'extended-choice=jenkins_jobs.modules.properties:extended_choice', 'github=jenkins_jobs.modules.properties:github', + 'heavy-job=jenkins_jobs.modules.properties:heavy_job', 'inject=jenkins_jobs.modules.properties:inject', 'ownership=jenkins_jobs.modules.properties:ownership', 'priority-sorter=jenkins_jobs.modules.properties:priority_sorter', diff --git a/tests/properties/fixtures/heavy-job.xml b/tests/properties/fixtures/heavy-job.xml new file mode 100644 index 000000000..1be17dd30 --- /dev/null +++ b/tests/properties/fixtures/heavy-job.xml @@ -0,0 +1,8 @@ + + + + + 2 + + + \ No newline at end of file diff --git a/tests/properties/fixtures/heavy-job.yaml b/tests/properties/fixtures/heavy-job.yaml new file mode 100644 index 000000000..48e9365ad --- /dev/null +++ b/tests/properties/fixtures/heavy-job.yaml @@ -0,0 +1,3 @@ +properties: + - heavy-job: + weight: 2