Add example to demonstrate flow plugin for job-template

Change-Id: I7bacce4f495989f8b37d6fc6b1bd773326e83b57
This commit is contained in:
Praveen Kumar 2014-12-20 09:03:18 +05:30
parent 1d3af0f3ce
commit 4bddf4c6ee
5 changed files with 101 additions and 10 deletions

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -21,17 +22,20 @@ the :ref:`Job` definition.
Requires the Jenkins `Build Flow Plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/Build+Flow+Plugin>`_
Example::
In order to use it for job-template you have to escape the curly braces by
doubling them in the DSL: { -> {{ , otherwise it will be interpreted by the
python str.format() command.
Job example:
.. literalinclude::
/../../tests/yamlparser/fixtures/project_flow_template001.yaml
Job template example:
.. literalinclude::
/../../tests/yamlparser/fixtures/project_flow_template002.yaml
job:
name: test_job
project-type: flow
dsl: |
build("job1")
parallel (
{ build("job2a") },
{ build("job2b") }
)
"""
import xml.etree.ElementTree as XML

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<com.cloudbees.plugins.flow.BuildFlow>
<dsl>build(&quot;job1&quot;)
parallel (
{ build(&quot;job2a&quot;) },
{ build(&quot;job2b&quot;) }
)
</dsl>
<actions/>
<description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<publishers/>
<buildWrappers/>
</com.cloudbees.plugins.flow.BuildFlow>

View File

@ -0,0 +1,9 @@
- job:
name: test_job
project-type: flow
dsl: |
build("job1")
parallel (
{ build("job2a") },
{ build("job2b") }
)

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<com.cloudbees.plugins.flow.BuildFlow>
<dsl>build(&quot;job1&quot;)
parallel (
{ build(&quot;job2a&quot;) },
{ build(&quot;job2b&quot;) }
)
build(&quot;job2c&quot;)
</dsl>
<actions/>
<description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<builders>
<hudson.tasks.Shell>
<command>unittest</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.tasks.Mailer>
<recipients>developer@nowhere.net</recipients>
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
<sendToIndividuals>false</sendToIndividuals>
</hudson.tasks.Mailer>
</publishers>
<buildWrappers/>
</com.cloudbees.plugins.flow.BuildFlow>

View File

@ -0,0 +1,26 @@
- job-template:
name: '{name}-unit-tests'
project-type: flow
dsl: |
build("job1")
parallel (
{{ build("job2a") }},
{{ build("job2b") }}
)
build("job2c")
builders:
- shell: unittest
publishers:
- email:
recipients: '{mail-to}'
- job-group:
name: '{name}-tests'
jobs:
- '{name}-unit-tests':
mail-to: developer@nowhere.net
- project:
name: project-name
jobs:
- '{name}-tests'