Jenkins "WorkflowScript: unexpected token" Jenkinsfile Parse Error
Jenkins could not parse your Jenkinsfile. The Groovy compiler hit a token it did not expect, so the pipeline failed before any stage executed.
What this error means
The build fails immediately at "Loading pipeline" with a WorkflowScript compilation error pointing at a line and column. No stage runs, and the same file fails identically every time.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 18: unexpected token: } @ line 18, column 1.
}
^
1 errorCommon causes
Unbalanced braces or parentheses
A missing or extra } or ) from an edited stage or steps block shifts the parser, which reports the error a few lines after the real mistake.
Broken string quoting
An unterminated "..." or a ${...} interpolation inside single quotes confuses the lexer and produces an unexpected-token error.
A directive in the wrong place
Putting a step outside steps {}, or environment / when in an invalid position, breaks the declarative grammar.
How to fix it
Validate the Jenkinsfile with the linter
- Run the pipeline-model-converter validator, which uses the same parser as the build.
- Read the exact line and column it reports.
curl -X POST -F "jenkinsfile=<Jenkinsfile" https://jenkins.example.com/pipeline-model-converter/validateBalance braces and fix quoting
- Open the reported line, then scan upward for the unclosed {, (, or string.
- Use double quotes when you need ${...} interpolation; single quotes are literal.
- Re-indent so block boundaries are visible.
How to prevent it
- Lint the Jenkinsfile in a pre-merge check and keep it small, moving logic into a unit-testable shared library.