jenkinsfile-runner
jenkinsfile-runner copied to clipboard
[JENKINS-56267] - introduce support for "dry-run" in Pipeline
jenkinsfile-runner allows to run Pipeline on developer's workstation before it get committed to SCM and ran by Jenkins. This prevents SCM history to look like
- Update Jenkinsfile to do some interesting stuff
- fix Jenkinsfile
- fix Jenkinsfile
- fix Jenkinsfile
- ...
On the other hand, running Pipeline on developer's workstation might not be feasible as the pipeline will have various side effects. You probably don't want to trigger a production deployment from your laptop while testing a fix.
I suggest we introduce support in jenkinsfile-runner for a Dry-Run mode in Pipeline execution. This will require explicit support in pipeline steps / shared libraries so they check for valid parameters but don't actually run stuff.
Same should apply to plain sh
steps. For those I suggest we define environment variable DRY_RUN
as a convention for script authors to support this use case. jenkinsfile-runner when set to run in dry-run mode would then take care to inject this to build environment.
I'm submitting this proposal as a github issue for initial feedback loop before I start writing some more concrete proposal as a doc in jenkinsfile-runner repository.
Yep, it is definitely good idea. Our commit history looks exactly like this :) We're trying to use Jenkins Pipeline Unit for that, but it becomes hard to write all these registerAllowedMethod()s for complex pipelines.
Really good idea ! There could have a JENKINS_PIPELINE_RUNMODE var set at job level, (perhaps a checkbox on the job config, or an option{} to add in the pipeline), and in a stage have the possibility to do somethting like :
stage('xyz') {
steps {
dryRun {
}
normal {
}
}
}
Or a if is DryRun
/ unless is DryRun
directive to add after any step.
The actual way to have Pipeline support a dry-run mode has to be discussed in the workflow-* projects, when available we could support it from jenkinsfile-runner, but for sure won't implement by ourself
We are closing GitHub issues for this repo. https://issues.jenkins-ci.org/browse/JENKINS-56267 was created as a follow-up so that it might be seen by other users and Pipeline maintainers.