Merge "Error on duplicate job names being found"

This commit is contained in:
Jenkins 2014-10-14 22:03:58 +00:00 committed by Gerrit Code Review
commit 1db5ad59c1
41 changed files with 757 additions and 0 deletions

View File

@ -74,6 +74,12 @@ job_builder section
(Optional) If set to True, jenkins job builder will search for job (Optional) If set to True, jenkins job builder will search for job
definition files recursively 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 jenkins section
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^

View File

@ -3,6 +3,7 @@ ignore_cache=True
keep_descriptions=False keep_descriptions=False
include_path=.:scripts:~/git/ include_path=.:scripts:~/git/
recursive=False recursive=False
allow_duplicates=False
[jenkins] [jenkins]
user=jenkins user=jenkins

View File

@ -157,6 +157,9 @@ class YamlParser(object):
"named '{0}'. Missing indent?" "named '{0}'. Missing indent?"
.format(n)) .format(n))
name = dfn['name'] name = dfn['name']
if name in group:
self._handle_dups("Duplicate entry found: '{0}' is "
"already defined".format(name))
group[name] = dfn group[name] = dfn
self.data[cls] = group self.data[cls] = group
@ -164,6 +167,15 @@ class YamlParser(object):
with open(fn) as fp: with open(fn) as fp:
self.parse_fp(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): def getJob(self, name):
job = self.data.get('job', {}).get(name, None) job = self.data.get('job', {}).get(name, None)
if not job: if not job:
@ -208,6 +220,8 @@ class YamlParser(object):
self.getXMLForJob(job) self.getXMLForJob(job)
for project in self.data.get('project', {}).values(): for project in self.data.get('project', {}).values():
logger.debug("XMLifying project '{0}'".format(project['name'])) 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', []): for jobspec in project.get('jobs', []):
if isinstance(jobspec, dict): if isinstance(jobspec, dict):
# Singleton dict containing dict of job-specific params # Singleton dict containing dict of job-specific params
@ -220,6 +234,11 @@ class YamlParser(object):
job = self.getJob(jobname) job = self.getJob(jobname)
if job: if job:
# Just naming an existing defined 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 continue
# see if it's a job group # see if it's a job group
group = self.getJobGroup(jobname) group = self.getJobGroup(jobname)
@ -235,6 +254,12 @@ class YamlParser(object):
group_jobparams = {} group_jobparams = {}
job = self.getJob(group_jobname) job = self.getJob(group_jobname)
if job: 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 continue
template = self.getJobTemplate(group_jobname) template = self.getJobTemplate(group_jobname)
# Allow a group to override parameters set by a project # Allow a group to override parameters set by a project
@ -259,6 +284,15 @@ class YamlParser(object):
raise JenkinsJobsException("Failed to find suitable " raise JenkinsJobsException("Failed to find suitable "
"template named '{0}'" "template named '{0}'"
.format(jobname)) .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): def getXMLForTemplateJob(self, project, template, jobs_filter=None):
dimensions = [] dimensions = []

View File

@ -31,6 +31,7 @@ DEFAULT_CONF = """
keep_descriptions=False keep_descriptions=False
ignore_cache=False ignore_cache=False
recursive=False recursive=False
allow_duplicates=False
[jenkins] [jenkins]
url=http://localhost:8080/ url=http://localhost:8080/

View File

View File

@ -0,0 +1,2 @@
[job_builder]
allow_duplicates = True

View File

@ -0,0 +1,49 @@
<?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.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>

View 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

View File

@ -0,0 +1,2 @@
[job_builder]
allow_duplicates = True

View File

@ -0,0 +1,19 @@
<?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>step2</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>

View 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'

View File

@ -0,0 +1,2 @@
[job_builder]
allow_duplicates = True

View File

@ -0,0 +1,49 @@
<?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.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>

View 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

View File

@ -0,0 +1,2 @@
[job_builder]
allow_duplicates = True

View File

@ -0,0 +1,49 @@
<?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.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>

View 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}

View File

@ -0,0 +1,2 @@
[job_builder]
allow_duplicates = True

View File

@ -0,0 +1,49 @@
<?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.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>

View 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

View File

@ -0,0 +1,98 @@
<?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.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>&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.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>

View 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}'

View File

@ -0,0 +1,98 @@
<?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.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>&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.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>

View 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}'

View 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

View 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

View 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'

View 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

View 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

View 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

View 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

View 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

View 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()