diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index f928f87d5..b8e4078f0 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -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. + `_ + + :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 diff --git a/setup.py b/setup.py index c3797bf94..1064168a4 100644 --- a/setup.py +++ b/setup.py @@ -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', diff --git a/tests/properties/fixtures/batch-task.xml b/tests/properties/fixtures/batch-task.xml new file mode 100644 index 000000000..9866cc66b --- /dev/null +++ b/tests/properties/fixtures/batch-task.xml @@ -0,0 +1,17 @@ + + + + + + + release + + + + say hello + + + + + + diff --git a/tests/properties/fixtures/batch-task.yaml b/tests/properties/fixtures/batch-task.yaml new file mode 100644 index 000000000..b11bb176f --- /dev/null +++ b/tests/properties/fixtures/batch-task.yaml @@ -0,0 +1,6 @@ +properties: + - batch-tasks: + - name: release + script: mvn -B release:prepare release:perform + - name: say hello + script: echo "Hello world"