Jenkins: WorkflowScript: expecting '}'
Jenkins: WorkflowScript: expecting '}'
DodaTech
2 min read
The Jenkins error “WorkflowScript: expecting ‘}’” means the Jenkins Pipeline parser reached the end of a file or block and expected a closing curly brace that was missing.
What It Means
Jenkins compiles your Jenkinsfile or pipeline script into a workflow. The Groovy parser found an unclosed block — a stage, steps, post, or conditional block that was opened with { but never closed with }.
Why It Happens
- A
stageorstepsblock is missing its closing}. - A
whencondition orenvironmentblock is not properly terminated. - Nested braces are mismatched — you closed a block in the wrong order.
- A directive like
tools,options, orparametersis missing its closing brace. - The script contains unmatched parentheses or brackets inside a block.
How to Fix It
1. Validate your Jenkinsfile locally
curl -X POST -u user:token \
-F "jenkinsfile=<Jenkinsfile" \
"https://jenkins.example.com/pipeline-model-converter/validate"2. Use a Groovy linter
groovy -e "println new File('Jenkinsfile').text"3. Check for unbalanced blocks
Ensure every { has a matching } at the correct indentation level:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
} // missing this line causes the error
}
}
}4. Use the Pipeline Syntax tool
In Jenkins job configuration, click Pipeline Syntax → Declarative Directive Generator to auto-generate correct block structures.
FAQ
Previous
ImportError: cannot import name '...'
Next
nginx: [alert] could not open error log file: Permission denied
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro