{"record":{"id":"2a00048e26cd0c8a","repo":"jenkinsci/jenkins","slug":"has-no-scm-trigger-but-checkscm-was-specified","errorCode":null,"errorMessage":"{} has no SCM trigger, but checkSCM was specified","messagePattern":"(.+?) has no SCM trigger, but checkSCM was specified","errorType":"exception","errorClass":"AbortException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/cli/BuildCommand.java","lineNumber":148,"sourceCode":"            for (ParameterDefinition pd : pdp.getParameterDefinitions()) {\n                if (parameters.containsKey(pd.getName()))\n                    continue;\n\n                // not passed in use default\n                ParameterValue defaultValue = pd.getDefaultParameterValue();\n                if (defaultValue == null) {\n                    throw new CmdLineException(null, String.format(\"No default value for the parameter '%s'.\", pd.getName()));\n                }\n                values.add(defaultValue);\n            }\n\n            a = new ParametersAction(values);\n        }\n\n        if (checkSCM) {\n            SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job);\n            if (item == null)\n                throw new AbortException(job.getFullDisplayName() + \" has no SCM trigger, but checkSCM was specified\");\n            // preemptively check for a polling veto\n            if (SCMDecisionHandler.firstShouldPollVeto(job) != null) {\n                return 0;\n            }\n            if (!item.poll(new StreamTaskListener(stdout, getClientCharset())).hasChanges())\n                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","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/cli/BuildCommand.java#L130-L166","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Configure SCM on the job: in job configuration, set up Source Code Management (Git, SVN, etc.).","Remove the --scm flag from the CLI command if SCM checking is not needed.","For Pipeline jobs, ensure the pipeline definition references an SCM source (e.g., Pipeline script from SCM)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check SCM support before using --scm\nSCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job);\nif (item == null && checkSCM) {\n    throw new AbortException(job.getFullDisplayName() + \" has no SCM trigger. Configure SCM or remove the --scm flag.\");\n}","typeGuard":"public static boolean hasSCMTrigger(Job<?, ?> job) {\n    return SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job) != null;\n}","tryCatchPattern":"try {\n    // build command run()\n} catch (AbortException e) {\n    if (e.getMessage().contains(\"has no SCM trigger\")) {\n        stderr.println(e.getMessage());\n        return 1;\n    }\n    throw e;\n}","preventionTips":["Verify the job has SCM configured before using the --scm flag.","For Pipeline jobs, ensure 'Pipeline script from SCM' is configured.","Remove the --scm flag if SCM checking is not needed."],"tags":["cli","build","scm","configuration"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}