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

Provide tokens for new and fixed warnings

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The token ANALYSIS_ISSUES_COUNT reports the total number of warnings per tool. It makes sense to add additional tokens (or a configuration of the current token) that allows to report the number of new and fixed warnings (and the delta).

      From the following requirements:

      In my environment Jenkins currently sends automatically eMails to the Build-Requester with the status of the build incl. the link to the Job.

      It would be great if it's possible to send directly the delta-report information of Warnings-NG, how many new warnings were introduced, how many solved, but I couldn't find out how to get this information within the pipeline.

      In the web-interface I already can see this:

      I don't think that all developers are clicking on the link in the mail, but they would if the notification mail would already say: "10 new warnings introduced, please check and correct!"

       

      Thanks!

        Attachments

          Activity

          Hide
          drulli Ulli Hafner added a comment - - edited

          Christian Treczoks The action from above has a getDisplayName() method that shows the link name in the side panel. Or you can call getLabelProvider() to obtain an instance of the `LabelProvider` that handles all of the labels.

          If you have a working example it would be quite helpful for others if we can put it into the Documentation.md file.

          Show
          drulli Ulli Hafner added a comment - - edited Christian Treczoks The action from above has a getDisplayName() method that shows the link name in the side panel. Or you can call getLabelProvider() to obtain an instance of the `LabelProvider` that handles all of the labels. If you have a working example it would be quite helpful for others if we can put it into the Documentation.md file.
          Hide
          drulli Ulli Hafner added a comment -

          Matthew Dews I have no idea on how to consume tokens in a declarative pipeline. Maybe here you should better ask on the mailing list or Gitter channel (or IRC).

          Show
          drulli Ulli Hafner added a comment - Matthew Dews I have no idea on how to consume tokens in a declarative pipeline. Maybe here you should better ask on the mailing list or Gitter channel (or IRC).
          Hide
          drulli Ulli Hafner added a comment - - edited

          I think, the best way would be to add a parameter to the existing token. This is simpler to implement and would reuse an already existing concept.

          We basically need a new parameter of type String that will be converted to an enum similar to QualityGateType. In this enum we should have a function object that handles the correct property to report. Then we can provide all different values just with one enum.

          So rather then using the hard coded getter action.getResult().getTotalSize(); we need to use enumInstance.getActualSizeMethodReference().apply(analysisResult);. The available properties are available in the interface AnalysisBuildResult. So the enum would probably look like:

              public enum IssueTokenType {
                  /** Total number of issues. */
                  TOTAL(AnalysisBuildResult::getTotalSize),
                  /** Total number of issues (severity Error). */
                  TOTAL_ERROR(r  -> r.getTotalSizeOf(Severity.ERROR)),
                  ....
                  /** Number of new issues. */
                  NEW(AnalysisBuildResult::getTotalSize),
                  /** Number of new issues (severity Error). */
                  NEW_ERROR(r  -> r.getNewSizeOf(Severity.ERROR)),
                  ....
                  /** Number of fixed issues. */
                  FIXED(AnalysisBuildResult::getFixedSize),
                 }
          
          
          Show
          drulli Ulli Hafner added a comment - - edited I think, the best way would be to add a parameter to the existing token. This is simpler to implement and would reuse an already existing concept. We basically need a new parameter of type String  that will be converted to an enum similar to QualityGateType . In this enum we should have a function object that handles the correct property to report. Then we can provide all different values just with one enum. So rather then using the hard coded getter action.getResult().getTotalSize(); we need to use enumInstance.getActualSizeMethodReference().apply(analysisResult); . The available properties are available in the interface AnalysisBuildResult . So the enum would probably look like: public enum IssueTokenType { /** Total number of issues. */ TOTAL(AnalysisBuildResult::getTotalSize), /** Total number of issues (severity Error). */ TOTAL_ERROR(r -> r.getTotalSizeOf(Severity.ERROR)), .... /** Number of new issues. */ NEW(AnalysisBuildResult::getTotalSize), /** Number of new issues (severity Error). */ NEW_ERROR(r -> r.getNewSizeOf(Severity.ERROR)), .... /** Number of fixed issues. */ FIXED(AnalysisBuildResult::getFixedSize), }
          Hide
          sladyn98 Sladyn Nunes added a comment -

          Makes sense to have them as it would, be like a swiss knife providing all the information we need right out of the box. I reckon we could add tests in the IssuesSizeTokenMacroTest and then add the relevant information to the Class.

          Show
          sladyn98 Sladyn Nunes added a comment - Makes sense to have them as it would, be like a swiss knife providing all the information we need right out of the box. I reckon we could add tests in the IssuesSizeTokenMacroTest and then add the relevant information to the Class.
          Hide
          drulli Ulli Hafner added a comment -

          Yes, exactly. The stub needs to be extended with the other properties. But the approach should be straightforward.

          Show
          drulli Ulli Hafner added a comment - Yes, exactly. The stub needs to be extended with the other properties. But the approach should be straightforward.

            People

            • Assignee:
              sladyn98 Sladyn Nunes
              Reporter:
              christiantreczoks Christian Treczoks
            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: