{"record":{"id":"730d0b97446d8844","repo":"jenkinsci/jenkins","slug":"build-scheduling-refused-by-an-extension-hence-no","errorCode":null,"errorMessage":"Build scheduling Refused by an extension, hence not in Queue.","messagePattern":"Build scheduling Refused by an extension, hence not in Queue\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/cli/BuildCommand.java","lineNumber":172,"sourceCode":"                return 0;\n        }\n\n        if (!job.isBuildable()) {\n            String msg = Messages.BuildCommand_CLICause_CannotBuildUnknownReasons(job.getFullDisplayName());\n            if (job instanceof ParameterizedJobMixIn.ParameterizedJob && ((ParameterizedJobMixIn.ParameterizedJob) job).isDisabled()) {\n                msg = Messages.BuildCommand_CLICause_CannotBuildDisabled(job.getFullDisplayName());\n            } else if (job.isHoldOffBuildUntilSave()) {\n                msg = Messages.BuildCommand_CLICause_CannotBuildConfigNotSaved(job.getFullDisplayName());\n            }\n            throw new IllegalStateException(msg);\n        }\n\n        Queue.Item item = ParameterizedJobMixIn.scheduleBuild2(job, 0, new CauseAction(new CLICause(Jenkins.getAuthentication2().getName())), a);\n        QueueTaskFuture<? extends Run<?, ?>> f = item != null ? (QueueTaskFuture) item.getFuture() : null;\n\n        if (wait || sync || follow) {\n            if (f == null) {\n                throw new IllegalStateException(BUILD_SCHEDULING_REFUSED);\n            }\n            Run<?, ?> b = f.waitForStart();    // wait for the start\n            stdout.println(\"Started \" + b.getFullDisplayName());\n            stdout.flush();\n\n            if (sync || follow) {\n                try {\n                    if (consoleOutput) {\n                        // read output in a retry loop, by default try only once\n                        // writeWholeLogTo may fail with FileNotFound\n                        // exception on a slow/busy machine, if it takes\n                        // longish to create the log file\n                        int retryInterval = 100;\n                        for (int i = 0; i <= retryCnt; ) {\n                            try {\n                                b.writeWholeLogTo(stdout);\n                                break;\n                            }","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/cli/BuildCommand.java#L154-L190","documentation":"Thrown by `BuildCommand.run()` at line 172 (constant `BUILD_SCHEDULING_REFUSED`) when the user passed -w, -s, or -f (wait/sync/follow) but `ParameterizedJobMixIn.scheduleBuild2(...)` returned a null `Queue.Item`, i.e. no future `f` exists. A null return means an extension (a Queue blocking handler, QueueSorter, or a plugin like Priority Sorter / Job Restrictions / a custom QueueDecisionHandler) refused to place the build in the queue, so there is nothing to wait on.","triggerScenarios":"Running `java -jar jenkins-cli.jar build <job> -s` (or -w/-f) where `scheduleBuild2` returns null because Jenkins is in quiet-down mode, a plugin vetoes queueing, the job has no available executors and a queue filter blocks it, or the item is collapsed by a QueueDecisionHandler.","commonSituations":"Jenkins in 'Prepare for Shutdown' / quiet-down (which blocks new items), a Queue plugin restricting concurrency, all executors offline with a 'block build when no node' filter, or plugin upgrades that changed queue acceptance behavior.","solutions":["Cancel Jenkins quiet-down (UI: 'Cancel quiet down', or `java -jar jenkins-cli.jar cancel-quiet-down`) then retry the build with -s/-w/-f.","Drop the -w/-s/-f flag so the command just submits the build (the null-future check is only inside the wait block); then inspect the queue separately.","Audit installed plugins for queue-restricting extensions (Priority Sorter, Job Restrictions, throttle-concurrency) and check the queue/executor state before submitting."],"exampleFix":"// before: build may be refused and -s has no future to wait on\n//   java -jar jenkins-cli.jar build myjob -s\n//\n// after: ensure not in quiet-down, then submit; optionally drop the wait flag\n//   java -jar jenkins-cli.jar cancel-quiet-down\n//   java -jar jenkins-cli.jar build myjob -s\n// (if still refused, submit without -s and poll the queue/HTTP API separately)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// scheduleBuild2 returning null only matters when you wait (-w/-s/-f);\n// submit without waiting, or detect null and report gracefully.\ntry {\n    // run build -s/-f\n} catch (IllegalStateException e) {\n    if (e.getMessage().equals(BuildCommand.BUILD_SCHEDULING_REFUSED)) {\n        // extension refused queueing: check quiet-down and queue plugins\n        System.err.println(\"Build refused by queue extension or quiet-down; \"\n          + \"run 'cancel-quiet-down' and retry, or submit without -s\");\n    } else throw e;\n}","preventionTips":["Ensure Jenkins is not in quiet-down before running build with -w/-s/-f.","Submit builds without wait flags when queueing behavior is uncertain, then poll separately."],"tags":["jenkins","cli","build","queue","scheduling","extension"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}