{"record":{"id":"9c05a9f0ce2b7281","repo":"jenkinsci/jenkins","slug":"no-default-value-for-the-parameter-s","errorCode":null,"errorMessage":"No default value for the parameter '%s'.","messagePattern":"No default value for the parameter '(.+?)'\\.","errorType":"validation","errorClass":"CmdLineException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/cli/BuildCommand.java","lineNumber":137,"sourceCode":"                            String.format(\"'%s' is not a valid parameter.\", name) :\n                            String.format(\"'%s' is not a valid parameter. Did you mean %s?\", name, nearest));\n                }\n                ParameterValue val = pd.createValue(this, Util.fixNull(e.getValue()));\n                if (val == null) {\n                    throw new CmdLineException(null, String.format(\"Cannot resolve the value for the parameter '%s'.\", name));\n                }\n                values.add(val);\n            }\n\n            // handle missing parameters by adding as default values ISSUE JENKINS-7162\n            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        }","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/cli/BuildCommand.java#L119-L155","documentation":"Thrown as a CmdLineException when iterating over the job's ParameterDefinitions and finding one that was not provided via -p AND has no default value (getDefaultParameterValue() returns null). This ensures all required parameters receive a value before the build is scheduled.","triggerScenarios":"During the 'fill in defaults' loop: a ParameterDefinition is not in the provided parameters map (parameters.containsKey(pd.getName()) is false), and pd.getDefaultParameterValue() returns null.","commonSituations":"A required parameter was added to the job but not supplied in the CLI call; a parameter definition's default value was cleared or never set; a custom ParameterDefinition type that doesn't implement getDefaultParameterValue properly.","solutions":["Provide the missing parameter via -p <name>=<value> in the CLI command.","Set a default value for the parameter in the job configuration so it is optional.","List all required parameters: check the job configuration for parameters without defaults."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check all required parameters are provided\nParametersDefinitionProperty pdp = job.getProperty(ParametersDefinitionProperty.class);\nif (pdp != null) {\n    for (ParameterDefinition pd : pdp.getParameterDefinitions()) {\n        if (!parameters.containsKey(pd.getName()) && pd.getDefaultParameterValue() == null) {\n            throw new AbortException(\"Required parameter '\" + pd.getName() + \"' was not provided and has no default.\");\n        }\n    }\n}","typeGuard":"public static boolean isParameterRequired(ParameterDefinition pd) {\n    return pd.getDefaultParameterValue() == null;\n}","tryCatchPattern":"try {\n    // build command run()\n} catch (CmdLineException e) {\n    if (e.getMessage().contains(\"No default value\")) {\n        stderr.println(e.getMessage());\n        stderr.println(\"Provide the missing parameter with -p <name>=<value>.\");\n        return 1;\n    }\n    throw e;\n}","preventionTips":["List all required parameters (those without defaults) before constructing the build command.","Set default values for optional parameters to avoid this error.","Use a parameter validation step in CI scripts to catch missing required parameters early."],"tags":["cli","build","parameters","validation","required-field"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}