{"record":{"id":"fcca7c0a1666e641","repo":"jenkinsci/jenkins","slug":"can-t-create-job-from-cli-in-fcca7c","errorCode":null,"errorMessage":"Can't create job from CLI in ","messagePattern":"Can't create job from CLI in ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/cli/CreateJobCommand.java","lineNumber":70,"sourceCode":"        Jenkins h = Jenkins.get();\n\n        if (h.getItemByFullName(name) != null) {\n            throw new IllegalStateException(\"Job '\" + name + \"' already exists\");\n        }\n\n        ModifiableTopLevelItemGroup ig = h;\n        int i = name.lastIndexOf('/');\n        if (i > 0) {\n            String group = name.substring(0, i);\n            Item item = h.getItemByFullName(group);\n            if (item == null) {\n                throw new IllegalArgumentException(\"Unknown ItemGroup \" + group);\n            }\n\n            if (item instanceof ModifiableTopLevelItemGroup) {\n                ig = (ModifiableTopLevelItemGroup) item;\n            } else {\n                throw new IllegalStateException(\"Can't create job from CLI in \" + group);\n            }\n            name = name.substring(i + 1);\n        }\n\n        Jenkins.checkGoodName(name);\n        ig.createProjectFromXML(name, stdin);\n        return 0;\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":80,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/cli/CreateJobCommand.java#L52-L80","documentation":"`CreateJobCommand.run()`: when NAME has a '/' and the prefix resolves to an existing item that is NOT a `ModifiableTopLevelItemGroup` (i.e. not a Folder), IllegalStateException 'Can't create job from CLI in <group>' is thrown at the else branch. You can only create child jobs inside modifiable groups.","triggerScenarios":"Running `create-job somejob/child < config.xml` where 'somejob' exists but is a non-folder item (a regular job).","commonSituations":"Using a job as a folder parent; no Folders plugin so no real modifiable group; misunderstanding item hierarchy.","solutions":["Target a Folder (ModifiableTopLevelItemGroup) as the parent.","Install and use the Folders plugin to host nested jobs.","Create at top level instead of nesting under a non-folder."],"exampleFix":"// before:\n//   # 'buildA' is a freestyle job, not a folder\n//   java -jar jenkins-cli.jar create-job buildA/sub < config.xml\n//   -> IllegalStateException: Can't create job from CLI in buildA\n//\n// after: parent must be a Folder\n//   java -jar jenkins-cli.jar create-job myFolder < folder.xml\n//   java -jar jenkins-cli.jar create-job myFolder/sub < config.xml","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Parent must be a Folder/modifiable group to host child jobs\nItem parent = h.getItemByFullName(group);\nif (parent != null && !(parent instanceof ModifiableTopLevelItemGroup)) {\n    throw new IllegalStateException(\"Not a folder: \" + group);\n}","tryCatchPattern":null,"preventionTips":["Nest jobs only under Folders, never under non-folder items.","Ensure the Folders plugin is installed for nested job creation."],"tags":["jenkins","cli","job","folder","itemgroup","create"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}