`WorkflowScript: 1: Missing required section "agent" @ line 1, column 1.`
BeginnerTroubleshootingJenkinsfile syntax, Groovy & CPS errors
Answer
Likely causes → The declarative pipeline {} block has no top-level agent, or it was put inside stages.
Diagnose →
curl -s -X POST -u alice:$TOKEN -F "jenkinsfile=<Jenkinsfile" https://jenkins/pipeline-model-converter/validate
Fix → Add agent any, agent none (with per-stage agents) or a specific agent directly under pipeline {.
Prevent → Lint Jenkinsfiles in a pre-commit hook or PR check with the validate endpoint.
More on Jenkinsfile syntax, Groovy & CPS errors
`Unknown stage section "step". Starting with version 0.5, steps in a stage must be in a ‘steps’ block.`Beginner`java.lang.NoSuchMethodError: No such DSL method 'withSonarQubeEnv' found among steps [archive, bat, build, ...]`Beginner`java.io.NotSerializableException: java.util.regex.Matcher`Advanced`java.io.NotSerializableException: groovy.json.internal.LazyMap`Intermediate`org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object`Intermediate`groovy.lang.MissingPropertyException: No such property: IMAGE_TAG for class: groovy.lang.Binding`Beginner