Interview Prep/CI/CD/Jenkins Build and Agent Failures

`WorkflowScript: 12: Expected a step @ line 12, column 5.` in a Declarative pipeline.

BeginnerTroubleshootingJenkins Build and Agent Failures
Answer

Likely causes → Plain Groovy (variable assignment, if) placed directly in steps {}; Declarative allows only steps there.

Diagnose → Read the line number in the error; lint with:

curl -X POST -u user:token -F "jenkinsfile=<Jenkinsfile" https://jenkins.example.com/pipeline-model-converter/validate

Fix → Wrap Groovy logic in script { ... }, or use when for conditions.

Prevent → Lint the Jenkinsfile in a pre-commit hook or PR check.

All CI/CD questions Roadmap: CI/CD fundamentals

More on Jenkins Build and Agent Failures