Jenkins PMD Plugin - How to show build failure report?

I am trying to use the Jenkins PMD plugin. Everything works fine except for one thing. If a Jenkins build fails, the reports in the build will not update. This can be a problem because if you have a critical error in your code, you have to go to the workspace manually and read the XML file (which is generated by the PMD) to find out what your error is.

I found someone who had the same problem, however this post was last updated in 2009. At the end of the post, you can see someone explaining that there is more to come. http://jenkins-ci.361315.n4.nabble.com/pmd-post-build-publishing-after-failing-build-td376948.html

I can confirm that it generates pmd results because I can see them in Jenkins workspace. However, reports will not appear in the assembly.

Jenkins console log (print screen due to VM): enter image description here

As you can see here, Jenkins build failed due to PMD rule violation. Which is good, however, when we go to build, you cannot see the PMD report.

enter image description here

I already installed the PMD plugin in Jenkins and it worked until I changed the ruleviolation. You can see my gradle code for PMD here:

task pmd (type: Pmd) {

ignoreFailures = false
description 'Run pmd'
group 'verification'
rulePriority = 2

ruleSets = ["java-android",
            "java-basic",
            "java-braces",
            "java-strings",
            "java-design",
            "java-unusedcode"]
source = fileTree('src/main/java')

reports {
    xml.enabled = true
    html.enabled = false
   }
}

check.doLast {
    project.tasks.getByName("pmd").execute()
}

      

+3


source to share


1 answer


So after a lot of searching and not finding anything. I started working on a workaround. I am using the Text-Finder plugin to find the text "PMD violations detected". When this text is found, the assembly will be modified to failure and the report will now be displayed.



Be careful, however, when you perform post-build actions after the PMD Violations line, those actions will not be performed. Therefore, change the design to unstable.

+1


source







All Articles