Interview Prep/Jenkins/Declarative pipeline syntax

How do you validate a Jenkinsfile without running it?

IntermediateConceptDeclarative pipeline syntax
Answer

Use the declarative linter via CLI or REST, and the "Replay" feature for quick experiments.

curl -s -X POST -u alice:$TOKEN -F "jenkinsfile=<Jenkinsfile" https://jenkins/pipeline-model-converter/validate
java -jar jenkins-cli.jar -s https://jenkins/ -auth alice:$TOKEN declarative-linter < Jenkinsfile

The linter checks syntax and structure only, not whether steps or credentials exist. Editors such as VS Code have Jenkinsfile extensions that call the same endpoint.

All Jenkins questions Roadmap: Jenkins

More on Declarative pipeline syntax