Jenkins "WorkflowScript: Missing required section" Declarative validation error
The Declarative pipeline model validates your Jenkinsfile before any stage runs. It found a required block (commonly agent or stages) missing, or a required parameter on a step left out, and aborts at parse time with a WorkflowScript error pointing at a line.
What this error means
The build fails immediately with org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed and a WorkflowScript: N: Missing required section (or Missing required parameter) message. No stage executes.
WorkflowScript: 2: Missing required section "agent" @ line 2, column 1.
pipeline {
^
WorkflowScript: 4: Missing required parameter: "name" @ line 4, column 13.
stage {
^
2 errorsCommon causes
A mandatory Declarative block is absent
A pipeline {} block must contain agent and stages; each stage must have a name argument. Omitting one fails the model validator before execution.
A step is missing a required parameter
A step (for example stage(...), git(...)) was written without the argument the validator marks required, so the compile step rejects it.
How to fix it
Add the section the validator names
- Read the line and the named section/parameter in the error.
- Add the missing
agent,stages, ornameargument so the model is complete. - Re-run; the validator passes once every required block is present.
pipeline {
agent any
stages {
stage('Build') {
steps { sh 'make' }
}
}
}How to prevent it
- Lint Jenkinsfiles with the "Declarative Linter" (
declarative-linterCLI or the/pipeline-model-converter/validateendpoint) before pushing. - Keep a known-good minimal pipeline as a template for new jobs.
- Prefer the Declarative editor or schema-aware tooling to catch missing blocks early.