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

Exclude skipped stages from estimated duration calculation

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • Jenkins ver. 2.52
      Plugins :
      - Pipeline 2.5
      - Pipeline: Basic Steps 2.4
      - Pipeline: Build Step 2.5
      - Pipeline: Stage Step 2.2
      - Pipeline: Input Step 2.5
      - Pipeline: Groovy 2.29

      Hello,

      I'm currently working on a Pipeline script that will execute multipe Stages depending on a parameter set in the Pipeline job (JenkinsFile attached). 

      Here is a sample of the JenkinsFile :

       

      pipeline {
      agent any
      
      stages {
           stage('Full Stop') {
                steps {
                      script { 
                            if (params.FULL_STOP == 'YES') {
                                  echo 'The application will now be stopped'
                            } else {
                                  echo 'Skipped'
                            }	
                      }
                }
           }
           stage('MQ') {
                steps {
                      script { 
                            if (params.MQ == 'YES') {
                                  echo 'Deployment of MQ'
                            } else {
                                  echo 'Skipped'
                            }	
                      }
                }
           }
           stage('Full Start') {
                steps {
                      script { 
                            if (params.FULL_START== 'YES') {
                                  echo 'The application will now be started'
                            } else {
                                  echo 'Skipped'
                            }	
                      }
                }
           }
      }
      }
      

      This code works fine but the issue here is that i can't really skip a Stage (i use currently the echo but this no doing the job).

      What i mean is that in the Stage View, there is a "Average stage times" that permit to have an average duration for a Stage, but when we skip a stage this duration isn't null but of 30 to 50ms (Screenshots attached).

      So the "Average stage times" isn't reliable because it does an average on all Build even if the Stage is skipped. Doing an average with a Stage during 3min with another one during 34ms falsified the "Average stage times".

      Is there is a way to really bypass/skip a stage depending on a parameter set in the job ?

      This will permit us to use the Stage View correctly.

      Thanks in advance for your help.

      Guillaume.

       

          [JENKINS-43826] Exclude skipped stages from estimated duration calculation

          when is designed to skip stages, but never less it affects average time and Stage View the same way.

          Alexander Vorobiev added a comment - when  is designed to skip stages, but never less it affects average time and Stage View the same way.

          better to have status skipped for stage to have vision that this step was skipped

          Viachaslau Kabak added a comment - better to have status skipped for stage to have vision that this step was skipped

          James Dumay added a comment -

          You should consider looking at using when to skip stages. Blue Ocean 1.2 will have proper visualisation support for this as part of JENKINS-39628.

          Example

          stage ('my stage') {
            when {
              expression { return true } 
            }
          }
          

          The blueocean-plugin component is not the appropriate place for stage view issues. Ill move this ticket to the correct component.

          James Dumay added a comment - You should consider looking at using when to skip stages. Blue Ocean 1.2 will have proper visualisation support for this as part of JENKINS-39628 . Example stage ( 'my stage' ) { when { expression { return true } } } The blueocean-plugin component is not the appropriate place for stage view issues. Ill move this ticket to the correct component.

          Guillaume Da Nobrega added a comment - - edited

          Hello jamesdumay,

          This is what i use now to skip a Stage (the When condition).

          But even with this condition the stage isn't fully skip since the stage last few ms. 

          So the average stage time stay unreliable and is false.

          Maybe an update permitting to really skip a stage if the When condition is used, can be usefull.

          Regards,

          Guillaume  

          Guillaume Da Nobrega added a comment - - edited Hello jamesdumay , This is what i use now to skip a Stage (the When condition). But even with this condition the stage isn't fully skip since the stage last few ms.  So the average stage time stay unreliable and is false. Maybe an update permitting to really skip a stage if the When condition is used, can be usefull. Regards, Guillaume  

          jessebs added a comment -

          When only works if the stage was skipped because of a foreseen reason.  If the stage is skipped because a previous stage failed, then the skipped stages are on the order of a few milliseconds and are considered during the average stage time calculation.

          jessebs added a comment - When only works if the stage was skipped because of a foreseen reason.  If the stage is skipped because a previous stage failed, then the skipped stages are on the order of a few milliseconds and are considered during the average stage time calculation.

            Unassigned Unassigned
            guillaumedanobrega Guillaume Da Nobrega
            Votes:
            15 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated: