How do you test a Jenkinsfile change without breaking the main pipeline?
IntermediateConceptJenkins
Answer
Options in increasing rigour: use the Replay feature on a run to edit and re-run the Jenkinsfile without committing; run the declarative linter (curl -X POST -F "jenkinsfile=<Jenkinsfile" $JENKINS_URL/pipeline-model-converter/validate); work on a branch, since multibranch builds use that branch's Jenkinsfile; and unit test shared libraries with JenkinsPipelineUnit. Use a staging Jenkins for plugin or core upgrades.
More on Jenkins
What is Jenkins and how is its architecture organised?BeginnerWhat are executors, nodes and labels in Jenkins?IntermediateWhy should you not run builds on the Jenkins controller?BeginnerHow do inbound (JNLP/WebSocket) and SSH agents connect to the controller?IntermediateWhat is a Jenkinsfile and where does it live?BeginnerDeclarative versus Scripted Pipeline: what are the differences?Intermediate