diff --git a/core/src/main/java/hudson/model/AbstractItem.java b/core/src/main/java/hudson/model/AbstractItem.java index 368a997dbf78..3cf29527827a 100644 --- a/core/src/main/java/hudson/model/AbstractItem.java +++ b/core/src/main/java/hudson/model/AbstractItem.java @@ -296,7 +296,7 @@ public HttpResponse doConfirmRename(@QueryParameter String newName) throws IOExc if (newName.equals(name)) { return FormValidation.warning(Messages.AbstractItem_NewNameUnchanged()); } - Jenkins.get().getProjectNamingStrategy().checkName(newName); + Jenkins.get().getProjectNamingStrategy().checkName(getParent().getFullName(), newName); checkIfNameIsUsed(newName); checkRename(newName); } catch (Failure e) { diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index e9a526ebbe6c..7c3fdbdadbc9 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -267,7 +267,7 @@ public synchronized T copy(T src, String name) throws I public synchronized TopLevelItem createProjectFromXML(String name, InputStream xml) throws IOException { acl.checkPermission(Item.CREATE); - Jenkins.get().getProjectNamingStrategy().checkName(name); + Jenkins.get().getProjectNamingStrategy().checkName(parent.getFullName(), name); Items.verifyItemDoesNotAlreadyExist(parent, name, null); Jenkins.checkGoodName(name); @@ -315,7 +315,7 @@ public synchronized TopLevelItem createProject(TopLevelItemDescriptor type, Stri type.checkApplicableIn(parent); acl.getACL().checkCreatePermission(parent, type); - Jenkins.get().getProjectNamingStrategy().checkName(name); + Jenkins.get().getProjectNamingStrategy().checkName(parent.getFullName(), name); Items.verifyItemDoesNotAlreadyExist(parent, name, null); Jenkins.checkGoodName(name); diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index d7444c2304b0..dd9d88ff25c9 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -1352,7 +1352,7 @@ public synchronized void doConfigSubmit(StaplerRequest req, final ProjectNamingStrategy namingStrategy = Jenkins.get().getProjectNamingStrategy(); if (namingStrategy.isForceExistingJobs()) { - namingStrategy.checkName(name); + namingStrategy.checkName(getParent().getFullName(), name); } FormApply.success(".").generateResponse(req, rsp, null); } catch (JSONException e) { diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index 6374dd3e3f49..c63d0a7be7a0 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -1085,7 +1085,8 @@ public FormValidation doCheckJobName(@QueryParameter String value) { try { Jenkins.checkGoodName(value); value = value.trim(); // why trim *after* checkGoodName? not sure, but ItemGroupMixIn.createTopLevelItem does the same - Jenkins.get().getProjectNamingStrategy().checkName(value); + ItemGroup parent = getOwner().getItemGroup(); + Jenkins.get().getProjectNamingStrategy().checkName(parent.getFullName(), value); } catch (Failure e) { return FormValidation.error(e.getMessage()); } diff --git a/core/src/main/java/jenkins/model/ProjectNamingStrategy.java b/core/src/main/java/jenkins/model/ProjectNamingStrategy.java index 3b4926fd7d09..cf4a895ba54f 100644 --- a/core/src/main/java/jenkins/model/ProjectNamingStrategy.java +++ b/core/src/main/java/jenkins/model/ProjectNamingStrategy.java @@ -66,11 +66,29 @@ public static DescriptorExtensionList