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

Warnings Plugin: Add ability to specify priority in dynamic parser

      I'm trying to add a new dynamic parser using the gui (via jenkins/configure). According to:
      http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.hudson.plugins/warnings/2.4/hudson/plugins/warnings/parser/Warning.java
      There's an overloaded Warnings constructor that allows you to specify a priority, but it must be of type Priority. I found this doc too:
      http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.hudson.plugins/warnings/2.4/hudson/plugins/warnings/util/model/Priority.java#Priority.valueOf%28java.lang.String%29

      I can't add the Priority enum import for some reason, adding the following gives me an error:
      import hudson.plugins.warnings.util.model.Priority

      Error:
      This is not a valid Groovy script: startup failed:
      Script1.groovy: 3: unable to resolve class hudson.plugins.warnings.util.model.Priority
      @ line 3, column 1.
      import hudson.plugins.warnings.util.model.Priority
      ^

      1 error

      Could there be an easy way to add priority to the dynamic parser?

          [JENKINS-12172] Warnings Plugin: Add ability to specify priority in dynamic parser

          Ulli Hafner added a comment -

          Seems that you picked the wrong import:

          import hudson.plugins.warnings.parser.Warning
          import hudson.plugins.analysis.util.model.Priority
          
          String fileName = matcher.group(1)
          String lineNumber = matcher.group(2)
          String category = matcher.group(3)
          String message = matcher.group(4)
          
          return new Warning(fileName, Integer.parseInt(lineNumber), "Dynamic Parser", category, message, Priority.HIGH);
          

          Ulli Hafner added a comment - Seems that you picked the wrong import: import hudson.plugins.warnings.parser.Warning import hudson.plugins.analysis.util.model.Priority String fileName = matcher.group(1) String lineNumber = matcher.group(2) String category = matcher.group(3) String message = matcher.group(4) return new Warning(fileName, Integer .parseInt(lineNumber), "Dynamic Parser" , category, message, Priority.HIGH);

          Ah thank you! In the first link I posted it's importing the hudson.plugins.warnings.util.model.Priority, so that's where I was getting that from.

          Tested and verified this works.

          -Devin

          Devin Linnington added a comment - Ah thank you! In the first link I posted it's importing the hudson.plugins.warnings.util.model.Priority, so that's where I was getting that from. Tested and verified this works. -Devin

            drulli Ulli Hafner
            devin_linnington Devin Linnington
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: