-
Bug
-
Resolution: Not A Defect
-
Minor
-
None
-
Jenkins LTS 2.138.3
Job DSL plugin 1.70
JaCoCo plugin 3.0.4
I configure the JaCoCo plugin by hand, trying to be as specific as possible: The paths are all configured for my project (wdl-util).
In the GUI, I can see Inclusions (e.g.: */.java,*/.groovy,*/.gs), which translates to the following in config.xml :
<hudson.plugins.jacoco.JacocoPublisher plugin="jacoco@3.0.4"> <execPattern>**/wdl-util/**/target/**.exec</execPattern> <classPattern>**/wdl-util/**/target/classes</classPattern> <sourcePattern>**/wdl-util/**/src/main/java</sourcePattern> <sourceInclusionPattern>**/*.java</sourceInclusionPattern> <sourceExclusionPattern></sourceExclusionPattern> <inclusionPattern>**/*.class</inclusionPattern> <exclusionPattern>**/*Test*.class</exclusionPattern> ...
When I run the job, this is what I see:
[JaCoCo plugin] Collecting JaCoCo coverage data... [JaCoCo plugin] **/wdl-util/**/target/**.exec;**/wdl-util/**/target/classes;**/wdl-util/**/src/main/java; locations are configured [JaCoCo plugin] Number of found exec files for pattern **/wdl-util/**/target/**.exec: 1 [JaCoCo plugin] Saving matched execfiles: /ige/jenkins/work/jobs/wdl-util/workspace/wdl-util/target/jacoco.exec [JaCoCo plugin] Saving matched class directories for class-pattern: **/wdl-util/**/target/classes: [JaCoCo plugin] - /ige/jenkins/work/jobs/wdl-util/workspace/wdl-util/target/classes 26 files [JaCoCo plugin] Saving matched source directories for source-pattern: **/wdl-util/**/src/main/java: [JaCoCo plugin] Source Inclusions: **/*.java [JaCoCo plugin] Source Exclusions: [JaCoCo plugin] - /ige/jenkins/work/jobs/wdl-util/workspace/wdl-util/src/main/java 32 files [JaCoCo plugin] Loading inclusions files.. [JaCoCo plugin] inclusions: [**/*.class] [JaCoCo plugin] exclusions: [**/*Test*.class] [JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=0, maxClass=0, minMethod=0, maxMethod=0, minLine=0, maxLine=0, minBranch=0, maxBranch=0, minInstruction=0, maxInstruction=0, minComplexity=0, maxComplexity=0] [JaCoCo plugin] Publishing the results.. [JaCoCo plugin] Loading packages.. [JaCoCo plugin] Done. [JaCoCo plugin] Overall coverage: class: 96, method: 88, line: 89, branch: 85, instruction: 89
Note the line with Source Inclusions.
Apparently, this is a part that I can't generate with the Job DSL plugin, since this option (and a couple of others that I can find in config.xml) are missing.
So, generating the job
publishers { jacocoCodeCoverage{ execPattern("**/${project}/**/target/**.exec") inclusionPattern("**/*.class") exclusionPattern("**/*Test*.class") classPattern("**/${project}/**/target/classes") sourcePattern("**/${project}/**/src/main/java") } }
results in the following config.xml :
<hudson.plugins.jacoco.JacocoPublisher> <execPattern>**/wdl-util/**/target/**.exec</execPattern> <classPattern>**/wdl-util/**/target/classes</classPattern> <sourcePattern>**/wdl-util/**/src/main/java</sourcePattern> <inclusionPattern>**/*.class</inclusionPattern> <exclusionPattern>**/*Test*.class</exclusionPattern> ...
sourceInclusionPattern and sourceExclusionPattern are missing.
When I open the job configuration, I can still see Inclusions (e.g.: */.java,*/.groovy,*/.gs) with a default value of */.java, but obviously, that's just a GUI thing.
Running the job gives me the following result:
[JaCoCo plugin] Collecting JaCoCo coverage data... [JaCoCo plugin] **/wdl-util/**/target/**.exec;**/wdl-util/**/target/classes;**/wdl-util/**/src/main/java; locations are configured [JaCoCo plugin] Number of found exec files for pattern **/wdl-util/**/target/**.exec: 1 [JaCoCo plugin] Saving matched execfiles: /ige/jenkins/work/jobs/wdl-util/workspace/wdl-util/target/jacoco.exec [JaCoCo plugin] Saving matched class directories for class-pattern: **/wdl-util/**/target/classes: [JaCoCo plugin] - /ige/jenkins/work/jobs/wdl-util/workspace/wdl-util/target/classes 26 files [JaCoCo plugin] Saving matched source directories for source-pattern: **/wdl-util/**/src/main/java: [JaCoCo plugin] Source Inclusions: null [JaCoCo plugin] Source Exclusions: null [JaCoCo plugin] - /ige/jenkins/work/jobs/wdl-util/workspace/wdl-util/src/main/java 32 files [JaCoCo plugin] Loading inclusions files.. [JaCoCo plugin] inclusions: [**/*.class] [JaCoCo plugin] exclusions: [**/*Test*.class] [JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=0, maxClass=0, minMethod=0, maxMethod=0, minLine=0, maxLine=0, minBranch=0, maxBranch=0, minInstruction=0, maxInstruction=0, minComplexity=0, maxComplexity=0] [JaCoCo plugin] Publishing the results.. [JaCoCo plugin] Loading packages.. [JaCoCo plugin] Done. [JaCoCo plugin] Overall coverage: class: 96, method: 88, line: 89, branch: 85, instruction: 89
Note that both source inclusion and exclusion are null!
And this results in not being able to see the source code in the JaCoCo plugin, for instance with the URL /job/wdl-util/lastBuild/jacoco/my.package/MyClass/
Thus: The Job DSL should support all the options of the JaCoCo plugin, since it results in a buggy user experience.
Note that using the direct XML editing works:
publishers { jacocoCodeCoverage{ execPattern("**/${project}/**/target/**.exec") inclusionPattern("**/*.class") exclusionPattern("**/*Test*.class") classPattern("**/${project}/**/target/classes") sourcePattern("**/${project}/**/src/main/java") } } configure { it / publishers / 'hudson.plugins.jacoco.JacocoPublisher' / 'sourceInclusionPattern'('**/*.java') { } }