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 created issue -

          Ulli Hafner added a comment - - edited

          So you mean adding a third option to QualityGateCriticality?
          and then use

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

          Ulli Hafner added a comment - - edited So you mean adding a third option to QualityGateCriticality ? and then use public void setResult( final Result result, final String message) { WarningAction existing = flowNode.getPersistentAction(WarningAction.class); if (existing == null || existing.getResult().isBetterThan(result)) { flowNode.addOrReplaceAction( new WarningAction(result).withMessage(message)); } }
          Ulli Hafner made changes -
          Component/s New: plugin-util-api-plugin [ 26521 ]
          Ulli Hafner made changes -
          Labels New: hacktoberfest

          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
          Ulli Hafner made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Ulli Hafner made changes -
          Labels Original: hacktoberfest
          Ulli Hafner made changes -
          Remote Link New: This issue links to "plugin-util-api #309 (Web Link)" [ 29300 ]

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

              Created:
              Updated:
              Resolved: