How can I test a change made to Jenkinsfile locally?

sorin picture sorin · Mar 30, 2016 · Viewed 120.8k times · Source

When writing jenkins pipelines it seems to be very inconvenient to commit each new change in order to see if it works.

Is there a way to execute these locally without committing the code?

Answer

Jesse Glick picture Jesse Glick · Mar 31, 2016

You cannot execute Pipeline script locally, since its whole purpose is to script Jenkins. (Which is one reason why it is best to keep your Jenkinsfile short and limited to code which actually deals with Jenkins features; your actual build logic should be handled with external processes or build tools which you invoke via a one-line sh or bat step.)

If you want to test a change to Jenkinsfile live but without committing it, use the Replay feature added in 1.14

JENKINS-33925 tracks the desired for an automated test framework.