Merge "Test creation of multiple jobs from templates"

This commit is contained in:
Jenkins 2014-05-20 22:18:18 +00:00 committed by Gerrit Code Review
commit 95be361ba9
5 changed files with 78 additions and 28 deletions

View File

@ -152,29 +152,7 @@ with those values. The example above would create the job called
The ``jobs:`` list can also allow for specifying job-specific
substitutions as follows::
- job-template:
name: '{name}-unit-tests'
builders:
- shell: unittest
publishers:
- email:
recipients: '{mail-to}'
- job-template:
name: '{name}-perf-tests'
builders:
- shell: perftest
publishers:
- email:
recipients: '{mail-to}'
- project:
name: project-name
jobs:
- '{name}-unit-tests':
mail-to: developer@nowhere.net
- '{name}-perf-tests':
mail-to: projmanager@nowhere.net
.. literalinclude:: /../../tests/yamlparser/fixtures/templates001.yaml
If a variable is a list, the job template will be realized with the
variable set to each value in the list. Multiple lists will lead to

View File

@ -4,10 +4,6 @@
- git:
url: 'http://example.org/'
- job:
name: 'scm_remote_deep_bug_job'
defaults: 'scm_remote_deep_bug_defs'
- job-template:
name: 'scm_remote_deep_bug_tpl'
defaults: 'scm_remote_deep_bug_defs'

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<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>perftest</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.tasks.Mailer>
<recipients>projmanager@nowhere.net</recipients>
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
<sendToIndividuals>false</sendToIndividuals>
</hudson.tasks.Mailer>
</publishers>
<buildWrappers/>
</project>
<?xml version="1.0" encoding="utf-8"?>
<project>
<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/>
</project>

View File

@ -0,0 +1,23 @@
- job-template:
name: '{name}-unit-tests'
builders:
- shell: unittest
publishers:
- email:
recipients: '{mail-to}'
- job-template:
name: '{name}-perf-tests'
builders:
- shell: perftest
publishers:
- email:
recipients: '{mail-to}'
- project:
name: project-name
jobs:
- '{name}-unit-tests':
mail-to: developer@nowhere.net
- '{name}-perf-tests':
mail-to: projmanager@nowhere.net

View File

@ -15,6 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import operator
import os
from ConfigParser import ConfigParser
from testtools import TestCase
@ -51,8 +52,10 @@ class TestCaseModuleYamlInclude(TestWithScenarios, TestCase, BaseTestCase):
# Generate the XML tree
parser.generateXML()
parser.jobs.sort(key=operator.attrgetter('name'))
# Prettify generated XML
pretty_xml = parser.jobs[0].output()
pretty_xml = "\n".join(job.output() for job in parser.jobs)
self.assertThat(
pretty_xml,