Merge "Added possibility to exclude project combinations"
This commit is contained in:
commit
dc7e1b0aa2
|
@ -121,6 +121,26 @@ additional variables can be specified for project variables. Example:
|
|||
|
||||
.. literalinclude:: /../../tests/yamlparser/fixtures/templates002.yaml
|
||||
|
||||
You can also specify some variable combinations to exclude from the matrix with
|
||||
the ``exclude`` keyword, to avoid generating jobs for those combinations. You
|
||||
can specify all the variables of the combination or only a subset, if you
|
||||
specify a subset, any value of the omited variable will match:
|
||||
|
||||
.. literalinclude:: /../../tests/yamlparser/fixtures/template_exclude.yaml
|
||||
|
||||
The above example will omit the jobs:
|
||||
|
||||
* build-axe1val1-axe2val1-axe3val2
|
||||
* build-axe1val1-axe2val2-axe3val1
|
||||
* build-axe1val2-axe2val2-axe3val1
|
||||
|
||||
To achieve the same without the ``exclude`` tag one would have to do something
|
||||
a bit more complicated, that gets more complicated for each dimension in the
|
||||
combination, for the previous example, the counterpart would be:
|
||||
|
||||
.. literalinclude::
|
||||
/../../tests/yamlparser/fixtures/template_without_exclude.yaml
|
||||
|
||||
Job Group
|
||||
^^^^^^^^^
|
||||
|
||||
|
|
|
@ -46,6 +46,29 @@ def matches(what, glob_patterns):
|
|||
for glob_pattern in glob_patterns)
|
||||
|
||||
|
||||
def combination_matches(combination, match_combinations):
|
||||
"""
|
||||
Checks if the given combination is matches for any of the given combination
|
||||
globs, being those a set of combinations where if a key is missing, it's
|
||||
considered matching
|
||||
|
||||
(key1=2, key2=3)
|
||||
|
||||
would match the combination match:
|
||||
(key2=3)
|
||||
|
||||
but not:
|
||||
(key1=2, key2=2)
|
||||
"""
|
||||
for cmatch in match_combinations:
|
||||
for key, val in combination.items():
|
||||
if cmatch.get(key, val) != val:
|
||||
break
|
||||
else:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class YamlParser(object):
|
||||
def __init__(self, config=None, plugins_info=None):
|
||||
self.data = {}
|
||||
|
@ -255,6 +278,7 @@ class YamlParser(object):
|
|||
# reject keys that are not useful during yaml expansion
|
||||
for k in ['jobs']:
|
||||
project.pop(k)
|
||||
excludes = project.pop('exclude', [])
|
||||
for (k, v) in project.items():
|
||||
tmpk = '{{{0}}}'.format(k)
|
||||
if tmpk not in template_name:
|
||||
|
@ -281,6 +305,10 @@ class YamlParser(object):
|
|||
|
||||
params.update(expanded_values)
|
||||
params = deep_format(params, params)
|
||||
if combination_matches(params, excludes):
|
||||
logger.debug('Excluding combination %s', str(params))
|
||||
continue
|
||||
|
||||
allow_empty_variables = self.config \
|
||||
and self.config.has_section('job_builder') \
|
||||
and self.config.has_option(
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
<?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>echo Combination axe1val1:axe2val1:axe3val1</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<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>echo Combination axe1val1:axe2val2:axe3val2</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<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>echo Combination axe1val2:axe2val1:axe3val1</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<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>echo Combination axe1val2:axe2val1:axe3val2</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<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>echo Combination axe1val2:axe2val2:axe3val2</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
- project:
|
||||
name: project-name
|
||||
axe1:
|
||||
- axe1val1
|
||||
- axe1val2
|
||||
axe2:
|
||||
- axe2val1
|
||||
- axe2val2
|
||||
axe3:
|
||||
- axe3val1
|
||||
- axe3val2
|
||||
exclude:
|
||||
- axe1: axe1val1
|
||||
axe2: axe2val1
|
||||
axe3: axe3val2
|
||||
- axe2: axe2val2
|
||||
axe3: axe3val1
|
||||
jobs:
|
||||
- build-{axe1}-{axe2}-{axe3}
|
||||
|
||||
- job-template:
|
||||
name: build-{axe1}-{axe2}-{axe3}
|
||||
builders:
|
||||
- shell: "echo Combination {axe1}:{axe2}:{axe3}"
|
|
@ -0,0 +1,99 @@
|
|||
<?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>echo Combination axe1val1:axe2val1:axe3val1</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<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>echo Combination axe1val1:axe2val2:axe3val2</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<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>echo Combination axe1val2:axe2val1:axe3val1</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<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>echo Combination axe1val2:axe2val1:axe3val2</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<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>echo Combination axe1val2:axe2val2:axe3val2</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
|
@ -0,0 +1,32 @@
|
|||
- project:
|
||||
name: project-name_comb1
|
||||
axe1:
|
||||
- axe1val1
|
||||
- axe1val2
|
||||
axe2: axe2val1
|
||||
axe3: axe3val1
|
||||
jobs:
|
||||
- build-{axe1}-{axe2}-{axe3}
|
||||
|
||||
- project:
|
||||
name: project-name_comb2
|
||||
axe1:
|
||||
- axe1val1
|
||||
- axe1val2
|
||||
axe2: axe2val2
|
||||
axe3: axe3val2
|
||||
jobs:
|
||||
- build-{axe1}-{axe2}-{axe3}
|
||||
|
||||
- project:
|
||||
name: project-name_comb3
|
||||
axe1: axe1val2
|
||||
axe2: axe2val1
|
||||
axe3: axe3val2
|
||||
jobs:
|
||||
- build-{axe1}-{axe2}-{axe3}
|
||||
|
||||
- job-template:
|
||||
name: build-{axe1}-{axe2}-{axe3}
|
||||
builders:
|
||||
- shell: "echo Combination {axe1}:{axe2}:{axe3}"
|
Loading…
Reference in New Issue