jenkinsci/jenkins · error · IllegalArgumentException
Unknown ItemGroup
Error message
Unknown ItemGroup
What it means
`CopyJobCommand.run()` parses the destination full name; if it contains '/', the prefix before the last '/' is treated as the parent ItemGroup. If `jenkins.getItemByFullName(group)` returns null (no such item), it throws IllegalArgumentException 'Unknown ItemGroup <group>'. The parent folder/group must pre-exist.
Source
Thrown at core/src/main/java/hudson/cli/CopyJobCommand.java:68
@Argument(metaVar = "DST", usage = "Name of the new job to be created.", index = 1, required = true)
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility")
public String dst;
@Override
protected int run() throws Exception {
Jenkins jenkins = Jenkins.get();
if (jenkins.getItemByFullName(dst) != null) {
throw new IllegalStateException("Job '" + dst + "' already exists");
}
ModifiableTopLevelItemGroup ig = jenkins;
int i = dst.lastIndexOf('/');
if (i > 0) {
String group = dst.substring(0, i);
Item item = jenkins.getItemByFullName(group);
if (item == null) {
throw new IllegalArgumentException("Unknown ItemGroup " + group);
}
if (item instanceof ModifiableTopLevelItemGroup) {
ig = (ModifiableTopLevelItemGroup) item;
} else {
throw new IllegalStateException("Can't create job from CLI in " + group);
}
dst = dst.substring(i + 1);
}
ig.copy(src, dst).save();
return 0;
}
}
View on GitHub (pinned to 2e228ff40b)
Solutions
- Create the parent folder first (Folders plugin / CloudBees Folders): `java -jar jenkins-cli.jar create-job myfolder < folder.xml` or via the UI, then copy into it.
- Correct the folder name spelling in the destination argument.
- Copy to a top-level name (no '/') if a folder isn't required.
Example fix
// before: // java -jar jenkins-cli.jar copy-job template typo/newjob // -> IllegalArgumentException: Unknown ItemGroup typo // // after: ensure the folder exists, then copy // java -jar jenkins-cli.jar create-job realfolder < folder-config.xml // java -jar jenkins-cli.jar copy-job template realfolder/newjob
Defensive patterns
Strategy: validation
Validate before calling
// For 'folder/name' destinations, verify the parent group exists
int i = dst.lastIndexOf('/');
if (i > 0) {
String group = dst.substring(0, i);
if (jenkins.getItemByFullName(group) == null) {
throw new IllegalArgumentException("Unknown ItemGroup " + group
+ " — create the folder first");
}
} Prevention
- Create parent folders before copying jobs into them.
- Validate each path segment of a nested destination resolves to an existing item.
When it happens
Trigger: Running `copy-job <src> myfolder/newjob` where 'myfolder' does not exist as an item in Jenkins.
Common situations: Typo in the folder name; expecting the command to create folders on the fly (it does not); targeting a folder path under a nested structure where an intermediate is missing.
Related errors
- Job ' already exists
- Can't create job from CLI in
- Unknown ItemGroup
- Can't create job from CLI in
- Job ' already exists
AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14).
Data as JSON: /api/errors/500cfc7e00bac071.
Report an issue: GitHub.