Search code examples
jenkinsjenkins-workflowjenkins-pipeline

How can I test a change made to Jenkinsfile locally?


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?


Solution

  • You cannot execute a 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 feature request for an automated test framework.