Merge "Error on duplicate job names being found"
This commit is contained in:
commit
1db5ad59c1
@ -74,6 +74,12 @@ job_builder section
|
||||
(Optional) If set to True, jenkins job builder will search for job
|
||||
definition files recursively
|
||||
|
||||
**allow_duplicates**
|
||||
(Optional) By default `jenkins-jobs` will abort any time a duplicate macro,
|
||||
template, job-group or job name is encountered as it cannot establish the
|
||||
correct one to use. When this option is set to True, only a warning is
|
||||
emitted.
|
||||
|
||||
jenkins section
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -3,6 +3,7 @@ ignore_cache=True
|
||||
keep_descriptions=False
|
||||
include_path=.:scripts:~/git/
|
||||
recursive=False
|
||||
allow_duplicates=False
|
||||
|
||||
[jenkins]
|
||||
user=jenkins
|
||||
|
@ -157,6 +157,9 @@ class YamlParser(object):
|
||||
"named '{0}'. Missing indent?"
|
||||
.format(n))
|
||||
name = dfn['name']
|
||||
if name in group:
|
||||
self._handle_dups("Duplicate entry found: '{0}' is "
|
||||
"already defined".format(name))
|
||||
group[name] = dfn
|
||||
self.data[cls] = group
|
||||
|
||||
@ -164,6 +167,15 @@ class YamlParser(object):
|
||||
with open(fn) as fp:
|
||||
self.parse_fp(fp)
|
||||
|
||||
def _handle_dups(self, message):
|
||||
|
||||
if not (self.config and self.config.has_section('job_builder') and
|
||||
self.config.getboolean('job_builder', 'allow_duplicates')):
|
||||
logger.error(message)
|
||||
raise JenkinsJobsException(message)
|
||||
else:
|
||||
logger.warn(message)
|
||||
|
||||
def getJob(self, name):
|
||||
job = self.data.get('job', {}).get(name, None)
|
||||
if not job:
|
||||
@ -208,6 +220,8 @@ class YamlParser(object):
|
||||
self.getXMLForJob(job)
|
||||
for project in self.data.get('project', {}).values():
|
||||
logger.debug("XMLifying project '{0}'".format(project['name']))
|
||||
# use a set to check for duplicate job references in projects
|
||||
seen = set()
|
||||
for jobspec in project.get('jobs', []):
|
||||
if isinstance(jobspec, dict):
|
||||
# Singleton dict containing dict of job-specific params
|
||||
@ -220,6 +234,11 @@ class YamlParser(object):
|
||||
job = self.getJob(jobname)
|
||||
if job:
|
||||
# Just naming an existing defined job
|
||||
if jobname in seen:
|
||||
self._handle_dups("Duplicate job '{0}' specified "
|
||||
"for project '{1}'".format(
|
||||
jobname, project['name']))
|
||||
seen.add(jobname)
|
||||
continue
|
||||
# see if it's a job group
|
||||
group = self.getJobGroup(jobname)
|
||||
@ -235,6 +254,12 @@ class YamlParser(object):
|
||||
group_jobparams = {}
|
||||
job = self.getJob(group_jobname)
|
||||
if job:
|
||||
if group_jobname in seen:
|
||||
self._handle_dups(
|
||||
"Duplicate job '{0}' specified for "
|
||||
"project '{1}'".format(group_jobname,
|
||||
project['name']))
|
||||
seen.add(group_jobname)
|
||||
continue
|
||||
template = self.getJobTemplate(group_jobname)
|
||||
# Allow a group to override parameters set by a project
|
||||
@ -259,6 +284,15 @@ class YamlParser(object):
|
||||
raise JenkinsJobsException("Failed to find suitable "
|
||||
"template named '{0}'"
|
||||
.format(jobname))
|
||||
# check for duplicate generated jobs
|
||||
seen = set()
|
||||
# walk the list in reverse so that last definition wins
|
||||
for job in self.jobs[::-1]:
|
||||
if job.name in seen:
|
||||
self._handle_dups("Duplicate definitions for job '{0}' "
|
||||
"specified".format(job.name))
|
||||
self.jobs.remove(job)
|
||||
seen.add(job.name)
|
||||
|
||||
def getXMLForTemplateJob(self, project, template, jobs_filter=None):
|
||||
dimensions = []
|
||||
|
@ -31,6 +31,7 @@ DEFAULT_CONF = """
|
||||
keep_descriptions=False
|
||||
ignore_cache=False
|
||||
recursive=False
|
||||
allow_duplicates=False
|
||||
|
||||
[jenkins]
|
||||
url=http://localhost:8080/
|
||||
|
0
tests/duplicates/__init__.py
Normal file
0
tests/duplicates/__init__.py
Normal file
2
tests/duplicates/fixtures/allow_duplicates001.conf
Normal file
2
tests/duplicates/fixtures/allow_duplicates001.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[job_builder]
|
||||
allow_duplicates = True
|
49
tests/duplicates/fixtures/allow_duplicates001.xml
Normal file
49
tests/duplicates/fixtures/allow_duplicates001.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?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.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
|
||||
<url>ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>**</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<clean>false</clean>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
</scm>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
18
tests/duplicates/fixtures/allow_duplicates001.yaml
Normal file
18
tests/duplicates/fixtures/allow_duplicates001.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
- project:
|
||||
name: duplicates
|
||||
version:
|
||||
- 1.1
|
||||
jobs:
|
||||
- 'duplicates002_{version}'
|
||||
|
||||
- job-template:
|
||||
name: 'duplicates002_{version}'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git
|
||||
|
||||
- job:
|
||||
name: duplicates002_1.1
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git
|
2
tests/duplicates/fixtures/allow_job_group001.conf
Normal file
2
tests/duplicates/fixtures/allow_job_group001.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[job_builder]
|
||||
allow_duplicates = True
|
19
tests/duplicates/fixtures/allow_job_group001.xml
Normal file
19
tests/duplicates/fixtures/allow_job_group001.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?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>step2</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
24
tests/duplicates/fixtures/allow_job_group001.yaml
Normal file
24
tests/duplicates/fixtures/allow_job_group001.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
- job-template:
|
||||
name: '{name}-1'
|
||||
builders:
|
||||
- shell: step1
|
||||
|
||||
- job-template:
|
||||
name: '{name}-2'
|
||||
builders:
|
||||
- shell: step2
|
||||
|
||||
- job-group:
|
||||
name: 'group-1'
|
||||
jobs:
|
||||
- '{name}-1'
|
||||
|
||||
- job-group:
|
||||
name: 'group-1'
|
||||
jobs:
|
||||
- '{name}-2'
|
||||
|
||||
- project:
|
||||
name: project-name
|
||||
jobs:
|
||||
- 'group-1'
|
2
tests/duplicates/fixtures/allow_macros001.conf
Normal file
2
tests/duplicates/fixtures/allow_macros001.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[job_builder]
|
||||
allow_duplicates = True
|
49
tests/duplicates/fixtures/allow_macros001.xml
Normal file
49
tests/duplicates/fixtures/allow_macros001.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?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.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
|
||||
<url>ssh://jenkins@review.openstack.org:29418/second.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>origin/stable-2</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<clean>false</clean>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
</scm>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
21
tests/duplicates/fixtures/allow_macros001.yaml
Normal file
21
tests/duplicates/fixtures/allow_macros001.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
- scm:
|
||||
name: project-scm
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/first.git
|
||||
branches:
|
||||
- origin/stable-1
|
||||
|
||||
- scm:
|
||||
name: project-scm
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/second.git
|
||||
branches:
|
||||
- origin/stable-2
|
||||
|
||||
- job:
|
||||
name: duplicate_macros
|
||||
scm:
|
||||
- project-scm
|
||||
|
2
tests/duplicates/fixtures/allow_projects001.conf
Normal file
2
tests/duplicates/fixtures/allow_projects001.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[job_builder]
|
||||
allow_duplicates = True
|
49
tests/duplicates/fixtures/allow_projects001.xml
Normal file
49
tests/duplicates/fixtures/allow_projects001.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?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.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
|
||||
<url>ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>origin/stable-2</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<clean>false</clean>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
</scm>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
15
tests/duplicates/fixtures/allow_projects001.yaml
Normal file
15
tests/duplicates/fixtures/allow_projects001.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
- project:
|
||||
name: duplicate-templates
|
||||
jobs:
|
||||
- '{name}-001':
|
||||
version: 1
|
||||
- '{name}-001':
|
||||
version: 2
|
||||
|
||||
- job-template:
|
||||
name: '{name}-001'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git
|
||||
branches:
|
||||
- origin/stable-{version}
|
2
tests/duplicates/fixtures/allow_templates001.conf
Normal file
2
tests/duplicates/fixtures/allow_templates001.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[job_builder]
|
||||
allow_duplicates = True
|
49
tests/duplicates/fixtures/allow_templates001.xml
Normal file
49
tests/duplicates/fixtures/allow_templates001.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?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.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
|
||||
<url>ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>origin/stable-2</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<clean>false</clean>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
</scm>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
20
tests/duplicates/fixtures/allow_templates001.yaml
Normal file
20
tests/duplicates/fixtures/allow_templates001.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
- project:
|
||||
name: duplicate-templates
|
||||
jobs:
|
||||
- '{name}-001'
|
||||
|
||||
- job-template:
|
||||
name: '{name}-001'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git
|
||||
branches:
|
||||
- origin/stable-1
|
||||
|
||||
- job-template:
|
||||
name: '{name}-001'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git
|
||||
branches:
|
||||
- origin/stable-2
|
98
tests/duplicates/fixtures/duplicates001.xml
Normal file
98
tests/duplicates/fixtures/duplicates001.xml
Normal file
@ -0,0 +1,98 @@
|
||||
<?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.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
|
||||
<url>ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>stable/1.1</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<clean>false</clean>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
</scm>
|
||||
<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.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
|
||||
<url>ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>stable/2.0</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<clean>false</clean>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
</scm>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
16
tests/duplicates/fixtures/duplicates001.yaml
Normal file
16
tests/duplicates/fixtures/duplicates001.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
- project:
|
||||
name: duplicates
|
||||
version:
|
||||
- 1.1
|
||||
jobs:
|
||||
- 'duplicates002_{version}'
|
||||
- 'duplicates002_{version}':
|
||||
version: 2.0
|
||||
|
||||
- job-template:
|
||||
name: 'duplicates002_{version}'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git
|
||||
branches:
|
||||
- 'stable/{version}'
|
98
tests/duplicates/fixtures/duplicates002.xml
Normal file
98
tests/duplicates/fixtures/duplicates002.xml
Normal file
@ -0,0 +1,98 @@
|
||||
<?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.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
|
||||
<url>ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>origin/stable-1.1</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<clean>false</clean>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
</scm>
|
||||
<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.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
|
||||
<url>ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>origin/stable-2.0</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<clean>false</clean>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
</scm>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
21
tests/duplicates/fixtures/duplicates002.yaml
Normal file
21
tests/duplicates/fixtures/duplicates002.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
- project:
|
||||
name: duplicates
|
||||
version:
|
||||
- 1.1
|
||||
jobs:
|
||||
- 'duplicate_job_group'
|
||||
- 'duplicate_job_group':
|
||||
version: 2.0
|
||||
|
||||
- job-group:
|
||||
name: duplicate_job_group
|
||||
jobs:
|
||||
- 'duplicates002_{version}'
|
||||
|
||||
- job-template:
|
||||
name: 'duplicates002_{version}'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git
|
||||
branches:
|
||||
- 'origin/stable-{version}'
|
11
tests/duplicates/fixtures/exception_duplicates001.yaml
Normal file
11
tests/duplicates/fixtures/exception_duplicates001.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
- job:
|
||||
name: duplicate001
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git
|
||||
|
||||
- job:
|
||||
name: duplicate001
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git
|
18
tests/duplicates/fixtures/exception_duplicates002.yaml
Normal file
18
tests/duplicates/fixtures/exception_duplicates002.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
- project:
|
||||
name: duplicates
|
||||
version:
|
||||
- 1.1
|
||||
jobs:
|
||||
- 'duplicates002_{version}'
|
||||
|
||||
- job-template:
|
||||
name: 'duplicates002_{version}'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git
|
||||
|
||||
- job:
|
||||
name: duplicates002_1.1
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git
|
20
tests/duplicates/fixtures/exception_job_group001.yaml
Normal file
20
tests/duplicates/fixtures/exception_job_group001.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
- job-template:
|
||||
name: '{name}-1'
|
||||
builders:
|
||||
- shell: step1
|
||||
|
||||
- job-template:
|
||||
name: '{name}-2'
|
||||
builders:
|
||||
- shell: step2
|
||||
|
||||
- job-group:
|
||||
name: 'group-1'
|
||||
|
||||
- job-group:
|
||||
name: 'group-1'
|
||||
|
||||
- project:
|
||||
name: project-name
|
||||
jobs:
|
||||
- 'group-1'
|
0
tests/duplicates/fixtures/exception_macros001.xml
Normal file
0
tests/duplicates/fixtures/exception_macros001.xml
Normal file
21
tests/duplicates/fixtures/exception_macros001.yaml
Normal file
21
tests/duplicates/fixtures/exception_macros001.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
- scm:
|
||||
name: project-scm
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/first.git
|
||||
branches:
|
||||
- origin/master
|
||||
|
||||
- scm:
|
||||
name: project-scm
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/second.git
|
||||
branches:
|
||||
- origin/master
|
||||
|
||||
- job:
|
||||
name: duplicate_macros
|
||||
scm:
|
||||
- project-scm
|
||||
|
0
tests/duplicates/fixtures/exception_projects001.xml
Normal file
0
tests/duplicates/fixtures/exception_projects001.xml
Normal file
13
tests/duplicates/fixtures/exception_projects001.yaml
Normal file
13
tests/duplicates/fixtures/exception_projects001.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
- project:
|
||||
name: duplicates
|
||||
version:
|
||||
- 1.1
|
||||
jobs:
|
||||
- 'duplicates002_1.1'
|
||||
- 'duplicates002_1.1'
|
||||
|
||||
- job:
|
||||
name: duplicates002_1.1
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git
|
0
tests/duplicates/fixtures/exception_projects002.xml
Normal file
0
tests/duplicates/fixtures/exception_projects002.xml
Normal file
13
tests/duplicates/fixtures/exception_projects002.yaml
Normal file
13
tests/duplicates/fixtures/exception_projects002.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
- project:
|
||||
name: duplicate-groups
|
||||
jobs:
|
||||
- 'group-001'
|
||||
- 'group-001'
|
||||
|
||||
- job-group:
|
||||
name: 'group-001'
|
||||
jobs:
|
||||
- dummy-job
|
||||
|
||||
- job:
|
||||
name: dummy-job
|
0
tests/duplicates/fixtures/exception_projects003.xml
Normal file
0
tests/duplicates/fixtures/exception_projects003.xml
Normal file
11
tests/duplicates/fixtures/exception_projects003.yaml
Normal file
11
tests/duplicates/fixtures/exception_projects003.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
- project:
|
||||
name: duplicate-templates
|
||||
jobs:
|
||||
- '{name}-001'
|
||||
- '{name}-001'
|
||||
|
||||
- job-template:
|
||||
name: '{name}-001'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git
|
16
tests/duplicates/fixtures/exception_templates001.yaml
Normal file
16
tests/duplicates/fixtures/exception_templates001.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
- project:
|
||||
name: duplicate-templates
|
||||
jobs:
|
||||
- '{name}-001'
|
||||
|
||||
- job-template:
|
||||
name: '{name}-001'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/jenkins-job-builder.git
|
||||
|
||||
- job-template:
|
||||
name: '{name}-001'
|
||||
scm:
|
||||
- git:
|
||||
url: ssh://jenkins@review.openstack.org:29418/openstack-infra/git-review.git
|
36
tests/duplicates/test_duplicates.py
Normal file
36
tests/duplicates/test_duplicates.py
Normal file
@ -0,0 +1,36 @@
|
||||
# Joint copyright:
|
||||
# - Copyright 2014 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import mock
|
||||
from testtools import TestCase, ExpectedException
|
||||
from testscenarios.testcase import TestWithScenarios
|
||||
from tests.base import get_scenarios, SingleJobTestCase
|
||||
from jenkins_jobs.errors import JenkinsJobsException
|
||||
|
||||
|
||||
class TestCaseModuleDuplicates(TestWithScenarios, TestCase,
|
||||
SingleJobTestCase):
|
||||
fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures')
|
||||
scenarios = get_scenarios(fixtures_path)
|
||||
|
||||
@mock.patch('jenkins_jobs.builder.logger', autospec=True)
|
||||
def test_yaml_snippet(self, mock_logger):
|
||||
|
||||
if self.in_filename.startswith("exception_"):
|
||||
with ExpectedException(JenkinsJobsException, "^Duplicate .*"):
|
||||
super(TestCaseModuleDuplicates, self).test_yaml_snippet()
|
||||
else:
|
||||
super(TestCaseModuleDuplicates, self).test_yaml_snippet()
|
Loading…
Reference in New Issue
Block a user