jenkinsci/jenkins · error · AbortException

{} has no SCM trigger, but checkSCM was specified

Error message

{} has no SCM trigger, but checkSCM was specified

What it means

Thrown as an AbortException when --scm (checkSCM) is specified but the job does not have an SCMTriggerItem (SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job) returns null). The --scm flag tells the build command to only proceed if there are SCM changes, but this requires the job to have SCM integration.

Source

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

            for (ParameterDefinition pd : pdp.getParameterDefinitions()) {
                if (parameters.containsKey(pd.getName()))
                    continue;

                // not passed in use default
                ParameterValue defaultValue = pd.getDefaultParameterValue();
                if (defaultValue == null) {
                    throw new CmdLineException(null, String.format("No default value for the parameter '%s'.", pd.getName()));
                }
                values.add(defaultValue);
            }

            a = new ParametersAction(values);
        }

        if (checkSCM) {
            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);
        }

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. Configure SCM on the job: in job configuration, set up Source Code Management (Git, SVN, etc.).
  2. Remove the --scm flag from the CLI command if SCM checking is not needed.
  3. For Pipeline jobs, ensure the pipeline definition references an SCM source (e.g., Pipeline script from SCM).
Defensive patterns

Strategy: validation

Validate before calling

// Check SCM support before using --scm
SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job);
if (item == null && checkSCM) {
    throw new AbortException(job.getFullDisplayName() + " has no SCM trigger. Configure SCM or remove the --scm flag.");
}

Type guard

public static boolean hasSCMTrigger(Job<?, ?> job) {
    return SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job) != null;
}

Try / catch

try {
    // build command run()
} catch (AbortException e) {
    if (e.getMessage().contains("has no SCM trigger")) {
        stderr.println(e.getMessage());
        return 1;
    }
    throw e;
}

Prevention

When it happens

Trigger: checkSCM is true (from CLI --scm/-f flag), but asSCMTriggerItem(job) returns null — the job has no SCM trigger configuration or is not an SCM-backed job type.

Common situations: Using --scm on a freestyle job with no Source Code Management section configured; using --scm on a job type that does not support SCM (e.g., some custom job types); Pipeline job without SCM polling configured.

Related errors


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