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

quality gate setting to only set stage to unstable except of whole build

      It would be nice to have the possibility to set only the stage result to unstable if quality gates are not satisfied. 
      e.g. like possible with the CatchErrorStep
      There it is handled with the following code snippet:

       

      if (buildResult.isWorseThan(Result.SUCCESS)) {
        context.get(Run.class).setResult(buildResult);
      }
      if (stepResult.isWorseThan(Result.SUCCESS)) {
        context.get(FlowNode.class).addOrReplaceAction(new WarningAction(stepResult).withMessage(message));
      } 

      Currently the warning-ng-plugin is using `io.jenkins.plugins.util.PipelineResultHandler`
      which always sets both the build and the stage result.

      public void setResult(final Result result, final String message) {
        run.setResult(result);
        WarningAction existing = flowNode.getPersistentAction(WarningAction.class);
        if (existing == null || existing.getResult().isBetterThan(result)) {
          flowNode.addOrReplaceAction(new WarningAction(result).withMessage(message));
        }
      } 

      In some usecases it would really be helpful to still visualize not met quality gates but not alter the whole build result.

      Or is there any workaround to already get the desired behaviour?

       

          [JENKINS-72059] quality gate setting to only set stage to unstable except of whole build

          Kevin Broselge added a comment - - edited

          Yes exactly or using an enum instead of the bool

          e.g. something like

           

          recordIssues(
            enabledForFailure: true, 
            qualityGates: [
              [threshold: 1, type: 'TOTAL_ERROR', unstable: Build],
              [threshold: 1, type: 'NEW', unstable: Stage]
            ],
            tool: msBuild()
          ) 

           

          Kevin Broselge added a comment - - edited Yes exactly or using an enum instead of the bool e.g. something like   recordIssues( enabledForFailure: true , qualityGates: [ [threshold: 1, type: 'TOTAL_ERROR' , unstable: Build], [threshold: 1, type: 'NEW' , unstable: Stage] ], tool: msBuild() )  

          Ulli Hafner added a comment -

          Does this make sense for failed as well? I.e. unstable stage or unstable build, failed stage or failed build?

          Ulli Hafner added a comment - Does this make sense for failed as well? I.e. unstable stage or unstable build, failed stage or failed build?

          Yes I think so, e.g. when introducing new tools/scanners and you don't want every old/legacy build to fail but still want to see if it works or not

          Kevin Broselge added a comment - Yes I think so, e.g. when introducing new tools/scanners and you don't want every old/legacy build to fail but still want to see if it works or not

          This change may be good for visualization, but I think the stage result that is set by the quality gate will regardless affect the execution of post blocks in subsequent stages, until JENKINS-57801 is fixed.

          Kalle Niemitalo added a comment - This change may be good for visualization, but I think the stage result that is set by the quality gate will regardless affect the execution of post blocks in subsequent stages, until JENKINS-57801 is fixed.

          Ulli Hafner added a comment -

          I'm not sure how the use case exactly should work. But with the new option the build status of the run is not altered anymore. Is that not sufficient?

          Ulli Hafner added a comment - I'm not sure how the use case exactly should work. But with the new option the build status of the run is not altered anymore. Is that not sufficient?

          that's enough for me

          Kevin Broselge added a comment - that's enough for me

          This change may broke the snippet generator for scanForIssues

          no public field ‘blameDisabled’ (or getter method) found in class io.jenkins.plugins.analysis.core.steps.ScanForIssuesStep

          Kevin Broselge added a comment - This change may broke the snippet generator for scanForIssues no public field ‘blameDisabled’ (or getter method) found in class io.jenkins.plugins.analysis.core.steps.ScanForIssuesStep

          Ulli Hafner added a comment -

          Are you running 10.2.0? I changed there https://github.com/jenkinsci/warnings-ng-plugin/pull/1690. I should have remove the setter as well...

          Ulli Hafner added a comment - Are you running 10.2.0? I changed there https://github.com/jenkinsci/warnings-ng-plugin/pull/1690 . I should have remove the setter as well...

          I'm running 11.2.0.

          Kevin Broselge added a comment - I'm running 11.2.0.

          Ulli Hafner added a comment -

          Ulli Hafner added a comment - Ok, I created https://github.com/jenkinsci/warnings-ng-plugin/pull/1703 .

            drulli Ulli Hafner
            thebro Kevin Broselge
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: