The Replay option in Jenkins pipelines allows you to rerun a completed build with temporary script modifications, enabling rapid debugging and iteration without committing changes to source control
The Replay feature in Jenkins Pipeline is a powerful debugging and development tool that lets you modify and re-execute a previously completed pipeline run without altering the original job configuration or Jenkinsfile in source control . When you select a completed build from the build history and click the "Replay" button in the left menu, Jenkins opens an editor displaying the exact pipeline script that was used for that run, along with any shared library code that was referenced . This allows you to make temporary edits, test fixes, or experiment with changes before committing them to your repository .
Replay works by retrieving the pipeline script from a completed build and presenting it for modification. Once you make your changes and run the replay, Jenkins creates a new build (with a new build number) using your modified script . The feature preserves the original build's parameters and environment context, making it particularly useful for testing small logic changes, debugging failing stages, or experimenting with fixes before committing them to version control . You can even replay builds that are still in progress, as long as the original pipeline was syntactically correct and able to start .
Multiple iterations: You can call Replay multiple times on the same original run, allowing easy parallel testing of different changes or approaches without creating multiple commits .
Shared library editing: If a pipeline run references a shared library, the shared library code is also displayed and can be modified as part of the Replay interface .
No configuration changes: Replay works without modifying the pipeline configuration or creating new commits, making it ideal for rapid prototyping and iteration .
Preserves context: The replayed build runs with the same parameters, SCM information, and other inputs as the original build, ensuring consistent testing conditions .
Replay has important limitations to be aware of. Pipeline runs with syntax errors cannot be replayed at all, meaning you cannot view their code or retrieve any changes made to them . For more significant modifications, it's recommended to save your changes externally before running them. Additionally, replayed pipeline behavior may differ slightly from runs started by other methods—for example, commit information might vary for pipelines that are not part of a multibranch pipeline .
Replay should not be confused with the Rebuild option provided by the Rebuilder plugin. Rebuild allows you to re-execute a completed job while changing parameters, whereas Replay directly displays and allows modification of the pipeline code itself . Replay is ideal for iterative testing of pipeline logic, while Rebuild is better suited for re-running jobs with different input parameters. Both approaches generate new build numbers and preserve the original build's context .