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

Add ability to always run particular stages when restarting

    Details

    • Similar Issues:
    • Sprint:
      Declarative backlog

      Description

      I would like to have the ability when restarting a pipeline to always execute a block before the restarted stages begin. The reasoning for this is that I may have some job setup that must always occur when restarting a particular stage.

      For example, consider the following:

      Setup -> Stage 1 -> Stage 2 -> Stage 3

      Let's say I would like to restart from Stage 2 but it needs the setup stage to function properly. Picking Stage 2 as the restart point would then trigger Setup, Stage 2, and then Stage 3.

      We already have a post block, so perhaps it would make sense to have a pre block that can be configured to run when a pipeline is restarted? Or perhaps you can just mark a stage to run even when restarted?

      I realize that it's probably a best practice to have each stage be modular and self-contained, but we have some data we must lay down on the  node that is unique to each run and later stages depend on it. Currently, it's just the first stage in our pipeline and it does not run if we restart the pipeline at a later stage.

      We had a small discussion regarding this in JENKINS-51932.

        Attachments

          Activity

          Hide
          abayer Andrew Bayer added a comment -

          This is an interesting possibility - no guarantees, but this does feel worth considering.

          Show
          abayer Andrew Bayer added a comment - This is an interesting possibility - no guarantees, but this does feel worth considering.
          Hide
          jonathank Jonathan Kuleff added a comment -

          I would really like this feature too.

          I have 2 use cases for this feature, the first is I would like to send a notification when a pipeline starts regardless of how it was triggered, there is no real nice way to do this currently for stage restarts.

          The second use case is I want to load some config/metadata that was generated from a skipped stage allowing me to restart from any stage, however because I can't know which will be the restarted stage I need to try load it in every stage and this just makes my Jenkinsfile look unnecessarily cluttered.

          In both cases having a pipeline pre stage would simplify my Jenkinsfile and declutter it making it easier to read and maintain

          Show
          jonathank Jonathan Kuleff added a comment - I would really like this feature too. I have 2 use cases for this feature, the first is I would like to send a notification when a pipeline starts regardless of how it was triggered, there is no real nice way to do this currently for stage restarts. The second use case is I want to load some config/metadata that was generated from a skipped stage allowing me to restart from any stage, however because I can't know which will be the restarted stage I need to try load it in every stage and this just makes my Jenkinsfile look unnecessarily cluttered. In both cases having a pipeline pre stage would simplify my Jenkinsfile and declutter it making it easier to read and maintain
          Hide
          harshavmb Harshavardhan Musanalli added a comment -

          This is one of the cool features we would like to have with jenkins. Many of our use cases are built around this and it really makes life much easier to restart the stage in parallel stages. 

          Show
          harshavmb Harshavardhan Musanalli added a comment - This is one of the cool features we would like to have with jenkins. Many of our use cases are built around this and it really makes life much easier to restart the stage in parallel stages. 
          Hide
          gc GC added a comment -

          I am also looking for this functionality for my use case. If my scm checkout and build phases run fine but test case execution fails, then in such case, i would like to run the checkout (which will now have fix for test case issue) and test case again but skip the build phase. Actually, the ability to run a particular phase as an optional feature will be the most ideal situation for me.

          Show
          gc GC added a comment - I am also looking for this functionality for my use case. If my scm checkout and build phases run fine but test case execution fails, then in such case, i would like to run the checkout (which will now have fix for test case issue) and test case again but skip the build phase. Actually, the ability to run a particular phase as an  optional  feature will be the most ideal situation for me.

            People

            • Assignee:
              abayer Andrew Bayer
              Reporter:
              bdevcich Blake Devcich
            • Votes:
              8 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated: