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

Post build steps appear in previous stage's steps

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • blueocean-plugin
    • None

      If(in declarative mode && last stages are parallel && you have a post{} pipeline block) {
          you don't see any of the post-build output, it's missing
      }
      

      Suggestion:
      Good DX would be; if in declarative mode, and you have defined a post{} pipeline block, then to create a stage named Post Build or something. It's consistent, predictable, very clear and clickable.

          [JENKINS-50449] Post build steps appear in previous stage's steps

          coervivek sophistifunk are you the best guys to talk to about this ?

          Paul Dragoonis added a comment - coervivek sophistifunk are you the best guys to talk to about this ?

          Vivek Pandey added a comment -

          We discussed following proposal:

          • Create synthetic `Pre` stage to represent all declarative pre stages. It should be created only if there is at least one pre declarative stage.
          • Create synthetic `Post` stage to represent all declarative post stages. It should be created only if there is at least one post declarative stage.
          • Pre synthetic stage status
          • Unstable if none of the pre-declarative-stages have failed AND at least one is unstable
          • Failed if at least one of the pre stage failed
          • success if all pre stages passed
          • Post synthetic stage status
          • Unstable if none of the post-declarative-stages have failed AND at least one is unstable
          • Failed if at least one of the post stage failed
          • success if all pre stages passed
          • All steps from declarative pre stages are shown under `Pre`
          • All steps from declarative post block are shown under `Post`

          To be specific, nodes and steps API needs these changes to incorporate pre and post stages.

          • /nodes API should return 'Pre' synthetic stage as first stage in pipeline only if there is at least one declarative pre synthetic stage
          • /nodes API should return 'Post' synthetic stage as last stage only if there is declarative post stage defined in the pipeline
          • /nodes/:nodeId/steps/ API where nodeId is Pre stage id, should return steps from all declarative pre-stages
          • /nodes/:nodeId/steps/ API where nodeId is Post stage id, should return steps from all declarative post-stages. For now there is only one post stage defined in the declarative pipeline but code should be generic to take multiple post in to account.
          • Add tests for pre and post stages and included steps

          Vivek Pandey added a comment - We discussed following proposal: Create synthetic `Pre` stage to represent all declarative pre stages. It should be created only if there is at least one pre declarative stage. Create synthetic `Post` stage to represent all declarative post stages. It should be created only if there is at least one post declarative stage . Pre synthetic stage status Unstable if none of the pre-declarative-stages have failed AND at least one is unstable Failed if at least one of the pre stage failed success if all pre stages passed Post synthetic stage status Unstable if none of the post-declarative-stages have failed AND at least one is unstable Failed if at least one of the post stage failed success if all pre stages passed All steps from declarative pre stages are shown under `Pre` All steps from declarative post block are shown under `Post` To be specific, nodes and steps API needs these changes to incorporate pre and post stages. /nodes API should return 'Pre' synthetic stage as first stage in pipeline only if there is at least one declarative pre synthetic stage /nodes API should return 'Post' synthetic stage as last stage only if there is declarative post stage defined in the pipeline /nodes/:nodeId/steps/ API where nodeId is Pre stage id, should return steps from all declarative pre-stages /nodes/:nodeId/steps/ API where nodeId is Post stage id, should return steps from all declarative post-stages. For now there is only one post stage defined in the declarative pipeline but code should be generic to take multiple post in to account. Add tests for pre and post stages and included steps

          Paul Dragoonis added a comment - - edited

          HI vivek thanks for the comprehensive proposal:

          If I have a post{} after my main stages{} block .. I expect to see a stage for this on the UI.

          `if there is at least one post declarative stage` this means I need `>1` post{} ? but you can only have one post{} at the end of the pipeline, so I'm a little confused.
          Based on the following syntax

          stages {
              ....
          }
          post {
              always { 
                  sh 'stuff''
              }
          }
          

          Paul Dragoonis added a comment - - edited HI vivek thanks for the comprehensive proposal: If I have a post{} after my main stages{} block .. I expect to see a stage for this on the UI. `if there is at least one post declarative stage` this means I need `>1` post{} ? but you can only have one post{} at the end of the pipeline, so I'm a little confused. Based on the following syntax stages { .... } post { always { sh 'stuff' ' } }

          Vivek Pandey added a comment -

          dragoonis Right, only one post stage at this time. Talking to abayer, we thought to write generic code so that if declarative marks more than one stages as post stages we collect steps from it. Thinking more about it, I think its better to restricts declarative spec to have at most one POST synthetic stage. cc abayer

          Vivek Pandey added a comment - dragoonis Right, only one post stage at this time. Talking to abayer , we thought to write generic code so that if declarative marks more than one stages as post stages we collect steps from it. Thinking more about it, I think its better to restricts declarative spec to have at most one POST synthetic stage. cc abayer

          Andrew Bayer added a comment -

          Works for me. Currently there's just one post synthetic stage, for the top-level post block, and I see no reason to expect there'd be a need for any more.

          Andrew Bayer added a comment - Works for me. Currently there's just one post synthetic stage, for the top-level post block, and I see no reason to expect there'd be a need for any more.

          abayer vivek can this be included into BO 1.6.0 ?

          Paul Dragoonis added a comment - abayer vivek can this be included into BO 1.6.0 ?

          Quim Vila added a comment -

          I am also facing this issue. Any plans to fix it for the next BO releases?

          Quim Vila added a comment - I am also facing this issue. Any plans to fix it for the next BO releases?

            Unassigned Unassigned
            dragoonis Paul Dragoonis
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: