Add support for batch_tasks.

Change-Id: I6cb6050322f07e90eadff88acab61c9ed66221fe
This commit is contained in:
Jaroslav Henner 2013-11-20 16:36:10 +01:00
parent 4ac4b88e5a
commit 2cad551ce5
4 changed files with 58 additions and 0 deletions

View File

@ -428,6 +428,40 @@ def build_blocker(parser, xml_parent, data):
XML.SubElement(blocker, 'blockingJobs').text = jobs
def batch_tasks(parser, xml_parent, data):
"""yaml: batch-tasks
Batch tasks can be tasks for events like releases, integration, archiving,
etc. In this way, anyone in the project team can execute them in a way that
leaves a record.
A batch task consists of a shell script and a name. When you execute
a build, the shell script gets run on the workspace, just like a build.
Batch tasks and builds "lock" the workspace, so when one of those
activities is in progress, all the others will block in the queue.
Requires the Jenkins `Batch Task Plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/Batch+Task+Plugin>`_
:arg list batch-tasks: Batch tasks.
:Task: * **name** (`str`) Task name.
* **script** (`str`) Task script.
Example:
.. literalinclude:: ../../tests/properties/fixtures/batch-task.yaml
"""
pdef = XML.SubElement(xml_parent,
'hudson.plugins.batch__task.BatchTaskProperty')
tasks = XML.SubElement(pdef, 'tasks')
for task in data:
batch_task = XML.SubElement(tasks,
'hudson.plugins.batch__task.BatchTask')
XML.SubElement(batch_task, 'name').text = task['name']
XML.SubElement(batch_task, 'script').text = task['script']
class Properties(jenkins_jobs.modules.base.Base):
sequence = 20

View File

@ -80,6 +80,7 @@ setuptools.setup(
('authenticated-build=jenkins_jobs.modules.properties:'
'authenticated_build'),
'authorization=jenkins_jobs.modules.properties:authorization',
'batch-tasks=jenkins_jobs.modules.properties:batch_tasks',
'build-blocker=jenkins_jobs.modules.properties:build_blocker',
'extended-choice=jenkins_jobs.modules.properties:extended_choice',
'github=jenkins_jobs.modules.properties:github',

View File

@ -0,0 +1,17 @@
<?xml version="1.0" ?>
<project>
<properties>
<hudson.plugins.batch__task.BatchTaskProperty>
<tasks>
<hudson.plugins.batch__task.BatchTask>
<name>release</name>
<script>mvn -B release:prepare release:perform</script>
</hudson.plugins.batch__task.BatchTask>
<hudson.plugins.batch__task.BatchTask>
<name>say hello</name>
<script>echo &quot;Hello world&quot;</script>
</hudson.plugins.batch__task.BatchTask>
</tasks>
</hudson.plugins.batch__task.BatchTaskProperty>
</properties>
</project>

View File

@ -0,0 +1,6 @@
properties:
- batch-tasks:
- name: release
script: mvn -B release:prepare release:perform
- name: say hello
script: echo "Hello world"