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

support some handling for skipped stages

    XMLWordPrintable

Details

    Description

      It would be really nice to support some steps in case a stage is skipped due to the when block. I understand the motivation in JENKINS-47577 not executing some post block for this. However, without some support for this, one cannot send an e-mail when a stage is skipped or inform other tools about this, that monitor pipelines for example.

      In my case this would render the really nice descriptive pipelines rather useless and I would have to stick to the scripted pipelines which results in a lot more code.

      Attachments

        Issue Links

          Activity

            abayer Andrew Bayer added a comment -

            I've thought some about this sort of thing - I'm considering maybe adding a finally post condition (which would also be helpful for JENKINS-41519, I think) that would always be run, regardless of build status, stage execution, etc, and would always be run after all other post conditions. But I'm not sure that directly addresses your use case - maybe a skipped post condition?

            In general, I really need to rewrite post entirely behind the scenes - there are a bunch of limitations its current implementation creates. Sigh. =)

            abayer Andrew Bayer added a comment - I've thought some about this sort of thing - I'm considering maybe adding a finally post condition (which would also be helpful for JENKINS-41519 , I think) that would always be run, regardless of build status, stage execution, etc, and would always be run after all other post conditions. But I'm not sure that directly addresses your use case - maybe a skipped post condition? In general, I really need to rewrite post entirely behind the scenes - there are a bunch of limitations its current implementation creates. Sigh. =)
            aklemp Andreas Klemp added a comment -

            A finally post would suffice if I could get the status (e.g. failure, success, skipped). However, the resulting conditions would contradict the descriptive nature, I think.

            As I understand (in addition to your comment in JENKINS-47577) that you propose it like this?

            stage ('foo') {
              when {
                ...
              }
              steps {
                ...
              }
              post {
                ...
                # run as usual when the stage is not skipped because of the when condition
              }
              skipped {
                ...
                # run when the stage is skipped because of the when condition
              }
              finally {
                ...
                # run in all cases after post/skipped or only after post when not skipped?
              }
            }

             

            aklemp Andreas Klemp added a comment - A finally post would suffice if I could get the status (e.g. failure, success, skipped). However, the resulting conditions would contradict the descriptive nature, I think. As I understand (in addition to your comment in JENKINS-47577 ) that you propose it like this? stage ( 'foo' ) { when { ... } steps { ... } post { ... # run as usual when the stage is not skipped because of the when condition } skipped { ... # run when the stage is skipped because of the when condition } finally { ... # run in all cases after post/skipped or only after post when not skipped? } }  
            pgrohe Phil Grohe added a comment - - edited

            Any news on this? I would find this useful too.

            I'd also like to point out that the documentation for the post block's cleanup condition is unclear and could be taken to mean it will run when a stage is skipped even though it doesn't.  If you interpret 'Skipped' as a possible stage status  (i.e. stageResult=NOT_BUILT I believe)

            cleanup
            Run the steps in this post condition after every other post condition has been evaluated, regardless of the Pipeline or stage’s status.

            https://www.jenkins.io/doc/book/pipeline/syntax/#post

            pgrohe Phil Grohe added a comment - - edited Any news on this? I would find this useful too. I'd also like to point out that the documentation for the post block's cleanup condition is unclear and could be taken to mean it will run when a stage is skipped even though it doesn't.  If you interpret 'Skipped' as a possible stage status  (i.e. stageResult=NOT_BUILT I believe) cleanup Run the steps in this post condition after every other post condition has been evaluated, regardless of the Pipeline or stage’s status . https://www.jenkins.io/doc/book/pipeline/syntax/#post

            As much as I hate bumps and their ilk, I'm also wondering if any effort has been made in this direction.  Much like the OP, I want to update GitHub's commit status checks with a skipped status for skipped stages rather than having them sit pending indefinitely.

            brianjmurrell Brian J Murrell added a comment - As much as I hate bump s and their ilk, I'm also wondering if any effort has been made in this direction.  Much like the OP, I want to update GitHub's commit status checks with a skipped status for skipped stages rather than having them sit pending indefinitely.

            People

              Unassigned Unassigned
              aklemp Andreas Klemp
              Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: