jenkinsfile-runner icon indicating copy to clipboard operation
jenkinsfile-runner copied to clipboard

[JENKINS-56267] - introduce support for "dry-run" in Pipeline

Open ndeloof opened this issue 6 years ago • 4 comments

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.

ndeloof avatar Apr 11 '18 09:04 ndeloof

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.

ababushk avatar May 16 '18 21:05 ababushk

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.

JiElPe-Fr38 avatar Oct 12 '18 09:10 JiElPe-Fr38

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

ndeloof avatar Oct 12 '18 09:10 ndeloof

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.

oleg-nenashev avatar Feb 25 '19 15:02 oleg-nenashev