Skip to content
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 stage or steps block is missing its closing }.
  • A when condition or environment block is not properly terminated.
  • Nested braces are mismatched — you closed a block in the wrong order.
  • A directive like tools, options, or parameters is 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 SyntaxDeclarative Directive Generator to auto-generate correct block structures.

FAQ

How do I find the exact line of the missing brace?
Jenkins shows the line number in the error message, e.g., “WorkflowScript: 12: expecting ‘}’”. The actual missing brace is often on the line above or at the end of the enclosing block.
What is the difference between Declarative and Scripted Pipeline?
Declarative uses a predefined structure with pipeline { agent ... stages { ... } }. Scripted uses Groovy directly. Missing braces are more common in Declarative because of its rigid block structure.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro