I'm trying to use the PMD plugin for Jenkins. Everything works fine except for one thing. When the Jenkins build fails, the reports in the build won't update. This could be a problem because if you've got a critical error in your code, you have to go to the workspace manually and read the .xml file (which is generated by PMD) to see 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 that someone explains that this isn't a feature yet. http://jenkins-ci.361315.n4.nabble.com/pmd-post-build-publishing-after-failing-build-td376948.html
I can confirm that he pmd results are being generated, because I can see them in my Jenkins' workspace. However, the reports won't show up in the build.
Jenkins console log (print screen because of VM):
As you can see here, the Jenkins build failed because of a PMD rule violation. Which is good, however when we go to the build, you can't see the PMD report.
I already installed the PMD plugin in Jenkins, and this used to work until I changed the ruleviolation. You can see my gradle's 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()
}
So after searching a lot and not finding anything. I started working on a workaround. I'm using the Text-Finder plugin to find the text "PMD violations found". When this text is found, the build is changed to failed and the report will now show up.
Be careful though, when you are running post-build actions after the line "PMD violations found", those actions won't be executed. So change the build to unstable instead.