jenkinsci/jenkins · error · IllegalStateException

Cannot build {0} because it is disabled.

Error message

Cannot build {0} because it is disabled.

What it means

Thrown as an IllegalStateException when job.isBuildable() returns false specifically because the job is disabled. The condition checks: job instanceof ParameterizedJobMixIn.ParameterizedJob AND ((ParameterizedJobMixIn.ParameterizedJob) job).isDisabled() returns true. The message comes from Messages.BuildCommand_CLICause_CannotBuildDisabled with the job's full display name.

Source

Thrown at core/src/main/java/hudson/cli/BuildCommand.java:164

            SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job);
            if (item == null)
                throw new AbortException(job.getFullDisplayName() + " has no SCM trigger, but checkSCM was specified");
            // preemptively check for a polling veto
            if (SCMDecisionHandler.firstShouldPollVeto(job) != null) {
                return 0;
            }
            if (!item.poll(new StreamTaskListener(stdout, getClientCharset())).hasChanges())
                return 0;
        }

        if (!job.isBuildable()) {
            String msg = Messages.BuildCommand_CLICause_CannotBuildUnknownReasons(job.getFullDisplayName());
            if (job instanceof ParameterizedJobMixIn.ParameterizedJob && ((ParameterizedJobMixIn.ParameterizedJob) job).isDisabled()) {
                msg = Messages.BuildCommand_CLICause_CannotBuildDisabled(job.getFullDisplayName());
            } else if (job.isHoldOffBuildUntilSave()) {
                msg = Messages.BuildCommand_CLICause_CannotBuildConfigNotSaved(job.getFullDisplayName());
            }
            throw new IllegalStateException(msg);
        }

        Queue.Item item = ParameterizedJobMixIn.scheduleBuild2(job, 0, new CauseAction(new CLICause(Jenkins.getAuthentication2().getName())), a);
        QueueTaskFuture<? extends Run<?, ?>> f = item != null ? (QueueTaskFuture) item.getFuture() : null;

        if (wait || sync || follow) {
            if (f == null) {
                throw new IllegalStateException(BUILD_SCHEDULING_REFUSED);
            }
            Run<?, ?> b = f.waitForStart();    // wait for the start
            stdout.println("Started " + b.getFullDisplayName());
            stdout.flush();

            if (sync || follow) {
                try {
                    if (consoleOutput) {
                        // read output in a retry loop, by default try only once
                        // writeWholeLogTo may fail with FileNotFound

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. Re-enable the job: in the Jenkins UI, click the job → 'Enable' button, or use 'jenkins-cli enable-job <name>'.
  2. If disabled by a failure-detection plugin, review and fix the underlying build failures first.
  3. Check the job's config.xml for <disabled>true</disabled> and set it to false if editing manually.
Defensive patterns

Strategy: validation

Validate before calling

// Check if job is disabled before attempting build
if (job instanceof ParameterizedJobMixIn.ParameterizedJob
        && ((ParameterizedJobMixIn.ParameterizedJob) job).isDisabled()) {
    throw new AbortException(job.getFullDisplayName() + " is disabled. Use 'enable-job' CLI command or enable via UI.");
}

Type guard

public static boolean isJobDisabled(Job<?, ?> job) {
    if (job instanceof ParameterizedJobMixIn.ParameterizedJob) {
        return ((ParameterizedJobMixIn.ParameterizedJob) job).isDisabled();
    }
    return false;
}

Try / catch

try {
    // build command run()
} catch (IllegalStateException e) {
    if (e.getMessage().contains("disabled")) {
        stderr.println(e.getMessage());
        stderr.println("Enable the job first: jenkins-cli enable-job <name>");
        return 1;
    }
    throw e;
}

Prevention

When it happens

Trigger: job.isBuildable() returns false; the job is a ParameterizedJobMixIn.ParameterizedJob; isDisabled() returns true.

Common situations: Job was manually disabled by an admin via the UI or API; job was disabled by a plugin after repeated build failures; job disabled during maintenance; job disabled as part of a decommissioning process.

Related errors


AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14). Data as JSON: /api/errors/04674b282e428e46. Report an issue: GitHub.