jenkins-job-builder/tests/yamlparser/fixtures/template_honor_defaults.xml
Antoine Musso 98b69476ea Apply defaults to job-templates parameters
I had the use case of a lot of projects sharing the same job template
that uses a lot of variables.  That requires each project to define all
the variables even if they are mostly identical.

This patch propose to define varialbes as 'defaults' and have them
applied in the job-template magically (oneline diffs always have that
feeling to me).

So instead of:

- project:
    name: project1
    arch: amd64
    builder: debuild
    lintian: true
    jobs:
     - '{name}-build-{arch}'

And so on ...

I can just:

- defaults:
    name: sanebuild

- project:
    name: project1
    defaults: sanebuild
    jobs:
     - '{name}-build-{arch}'

And override the arch as needed either in the project or by passing it
to the job.

Without this patch, the provided yamlparser fixture
template_honor_defaults.yaml would raise:

    arch parameter missing to format echo Build arch {arch}.
    Given: {'': '', 'jobs': ['build-{arch}'], 'name': 'project-name'}

Change-Id: Ida1e27eb47356d9cae42175743bd2fd52eb9d869
2014-08-22 23:35:54 +02:00

40 lines
1.2 KiB
XML

<?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>echo Build arch amd64.</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>
<BLANKLINE>
<?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>echo Build arch i386.</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>