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.
More on Declarative pipeline syntax
What is the minimum valid declarative pipeline?BeginnerWhat agent types exist in declarative pipelines?IntermediateWhen do you use `agent none` at the top level?IntermediateHow do nested sequential stages work and why are they useful?IntermediateList the `post` conditions and when each fires.IntermediateWhat are the most useful `when` conditions?Intermediate