jenkinsci/jenkins · error · IllegalArgumentException
Unknown ItemGroup
Error message
Unknown ItemGroup
What it means
`CreateJobCommand.run()`: when NAME contains '/', the prefix before the last '/' is the parent ItemGroup. If `h.getItemByFullName(group)` returns null, IllegalArgumentException 'Unknown ItemGroup <group>' is thrown. The parent group must already exist (CreateJobCommand does not create intermediate folders).
Source
Thrown at core/src/main/java/hudson/cli/CreateJobCommand.java:64
@Argument(metaVar = "NAME", usage = "Name of the job to create", required = true)
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility")
public String name;
@Override
protected int run() throws Exception {
Jenkins h = Jenkins.get();
if (h.getItemByFullName(name) != null) {
throw new IllegalStateException("Job '" + name + "' already exists");
}
ModifiableTopLevelItemGroup ig = h;
int i = name.lastIndexOf('/');
if (i > 0) {
String group = name.substring(0, i);
Item item = h.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);
}
name = name.substring(i + 1);
}
Jenkins.checkGoodName(name);
ig.createProjectFromXML(name, stdin);
return 0;
}
}
View on GitHub (pinned to 2e228ff40b)
Solutions
- Create the parent Folder first (Folders plugin), then create the job inside it.
- Correct the folder name in the argument.
- Create the job at top level (no '/') if nesting isn't needed.
Example fix
// before: // java -jar jenkins-cli.jar create-job misspelled/newjob < config.xml // -> IllegalArgumentException: Unknown ItemGroup misspelled // // after: create/verify the folder, then the job // java -jar jenkins-cli.jar create-job services < folder.xml // java -jar jenkins-cli.jar create-job services/newjob < config.xml
Defensive patterns
Strategy: validation
Validate before calling
// Verify parent group exists for nested names
int i = name.lastIndexOf('/');
if (i > 0) {
String group = name.substring(0, i);
if (h.getItemByFullName(group) == null)
throw new IllegalArgumentException("Unknown ItemGroup " + group);
} Prevention
- Pre-create folders before creating nested jobs via CLI.
- Validate intermediate path segments exist before create-job.
When it happens
Trigger: Running `create-job myfolder/newjob < config.xml` where 'myfolder' is not an existing item.
Common situations: Typo in the folder portion; assuming folders are auto-created; missing an intermediate parent in a deep path.
Related errors
- Can't create job from CLI in
- Unknown ItemGroup
- Can't create job from CLI in
- Job ' already exists
- Job ' already exists
AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14).
Data as JSON: /api/errors/422b0050842992da.
Report an issue: GitHub.