Merge "Test creation of multiple jobs from templates"
This commit is contained in:
commit
95be361ba9
@ -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
|
The ``jobs:`` list can also allow for specifying job-specific
|
||||||
substitutions as follows::
|
substitutions as follows::
|
||||||
|
|
||||||
- job-template:
|
.. literalinclude:: /../../tests/yamlparser/fixtures/templates001.yaml
|
||||||
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
|
|
||||||
|
|
||||||
If a variable is a list, the job template will be realized with the
|
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
|
variable set to each value in the list. Multiple lists will lead to
|
||||||
|
@ -4,10 +4,6 @@
|
|||||||
- git:
|
- git:
|
||||||
url: 'http://example.org/'
|
url: 'http://example.org/'
|
||||||
|
|
||||||
- job:
|
|
||||||
name: 'scm_remote_deep_bug_job'
|
|
||||||
defaults: 'scm_remote_deep_bug_defs'
|
|
||||||
|
|
||||||
- job-template:
|
- job-template:
|
||||||
name: 'scm_remote_deep_bug_tpl'
|
name: 'scm_remote_deep_bug_tpl'
|
||||||
defaults: 'scm_remote_deep_bug_defs'
|
defaults: 'scm_remote_deep_bug_defs'
|
||||||
|
50
tests/yamlparser/fixtures/templates001.xml
Normal file
50
tests/yamlparser/fixtures/templates001.xml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<actions/>
|
||||||
|
<description><!-- Managed by Jenkins Job Builder --></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><!-- Managed by Jenkins Job Builder --></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>
|
23
tests/yamlparser/fixtures/templates001.yaml
Normal file
23
tests/yamlparser/fixtures/templates001.yaml
Normal 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
|
@ -15,6 +15,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import operator
|
||||||
import os
|
import os
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
from testtools import TestCase
|
from testtools import TestCase
|
||||||
@ -51,8 +52,10 @@ class TestCaseModuleYamlInclude(TestWithScenarios, TestCase, BaseTestCase):
|
|||||||
# Generate the XML tree
|
# Generate the XML tree
|
||||||
parser.generateXML()
|
parser.generateXML()
|
||||||
|
|
||||||
|
parser.jobs.sort(key=operator.attrgetter('name'))
|
||||||
|
|
||||||
# Prettify generated XML
|
# Prettify generated XML
|
||||||
pretty_xml = parser.jobs[0].output()
|
pretty_xml = "\n".join(job.output() for job in parser.jobs)
|
||||||
|
|
||||||
self.assertThat(
|
self.assertThat(
|
||||||
pretty_xml,
|
pretty_xml,
|
||||||
|
Loading…
Reference in New Issue
Block a user