Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51932

Directive Generator: `when` is missing `isRestartedRun()`

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Jenkins:
      - Core 2.127
      - Experimental UC plugins
      - Declarative at 1.3.0-SNAPSHOT, which was master at commit eeb92e42

      Summary
      When using the Directive Generator, the generator for when is missing isRestartedRun().

      Steps to recreate
      1. Go to the Declarative Directive Generator via http://1.2.3.4:8080/job/your-pipeline-job/directive-generator/

      2. Pick the Sample Directive: when

      3. Look in the dropdown for When Condition. I was expecting to see `isRestartedRun`, but it's not there.

          [JENKINS-51932] Directive Generator: `when` is missing `isRestartedRun()`

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/279

          Blake Devcich added a comment - - edited

          Is there documentation how this this isRestartedRun is used? If I put this in the when block of stage 1 and restart at stage 3 will it skip the stage 1 block or will it actually do stage 1 first, and then stage 3 and so on?

          I ask because I'm looking for a way to always run an earlier stage (to do some setup) no matter what stage is selected as the restart point.

          https://jenkins.io/doc/book/pipeline/syntax/#when makes no mention of this feature.

          Blake Devcich added a comment - - edited Is there documentation how this this isRestartedRun is used? If I put this in the when block of stage 1 and restart at stage 3 will it skip the stage 1 block or will it actually do stage 1 first, and then stage 3 and so on? I ask because I'm looking for a way to always run an earlier stage (to do some setup) no matter what stage is selected as the restart point. https://jenkins.io/doc/book/pipeline/syntax/#when makes no mention of this feature.

          Andrew Bayer added a comment -

          It allows you to only fire a stage if it's part of a restarted run (or, of course, with not, you can have it do the reverse). But this still only applies for stages from the restart point onward - if you restart at stage 3, stages 1 and 2 will always be skipped regardless.

          Andrew Bayer added a comment - It allows you to only fire a stage if it's part of a restarted run (or, of course, with not , you can have it do the reverse). But this still only applies for stages from the restart point onward - if you restart at stage 3, stages 1 and 2 will always be skipped regardless.

          Blake Devcich added a comment -

          Thanks Andrew! So just to confirm there's no way to always run a setup stage when a pipeline is restarted?

          The only thing I can think of right now is to have a function that is called in the beginning of every stage that is executed only on a restart.

          Blake Devcich added a comment - Thanks Andrew! So just to confirm there's no way to always run a setup stage when a pipeline is restarted? The only thing I can think of right now is to have a function that is called in the beginning of every stage that is executed only on a restart.

          Andrew Bayer added a comment -

          bdevcich - correct. It's an interesting idea, though - probably would be worth opening a JIRA for that as a new feature.

          Andrew Bayer added a comment - bdevcich - correct. It's an interesting idea, though - probably would be worth opening a JIRA for that as a new feature.

          Andrew Bayer added a comment -

          This'll be in the next release (1.3.2)

          Andrew Bayer added a comment - This'll be in the next release (1.3.2)

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

            abayer Andrew Bayer
            kshultz Karl Shultz
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: