[JIRA] (JENKINS-56580) Configuration for JaCoCo plugin doesn't generate source inclusions

2 views
Skip to first unread message

cristalp@java.net (JIRA)

unread,
Mar 15, 2019, 6:50:02 AM3/15/19
to jenkinsc...@googlegroups.com
cristalp created an issue
 
Jenkins / Bug JENKINS-56580
Configuration for JaCoCo plugin doesn't generate source inclusions
Issue Type: Bug Bug
Assignee: Daniel Spilker
Components: job-dsl-plugin
Created: 2019-03-15 10:49
Environment: Jenkins LTS 2.138.3
Job DSL plugin 1.70
JaCoCo plugin 3.0.4
Priority: Minor Minor
Reporter: cristalp

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="jac...@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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

cristalp@java.net (JIRA)

unread,
Mar 15, 2019, 7:18:02 AM3/15/19
to jenkinsc...@googlegroups.com
cristalp updated an issue
Change By: cristalp
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}} :

{code:xml}

    <hudson.plugins.jacoco.JacocoPublisher plugin="jac...@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>
      ...
{code}


When I run the job, this is what I see:
{code}

[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
{code}


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
{code:groovy}

    publishers {
        jacocoCodeCoverage{
          execPattern("**/${project}/**/target/**.exec")
          inclusionPattern("**/*.class")
          exclusionPattern("**/*Test*.class")
          classPattern("**/${project}/**/target/classes")
          sourcePattern("**/${project}/**/src/main/java")
        }
      }
{code}


results in the following {{config.xml}} :
{code: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>
            ...
{code}

{{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:
{code}

[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
{code}


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:
{code:xml}

    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') {
      }
    }

{code}

cristalp@java.net (JIRA)

unread,
Mar 15, 2019, 7:18:03 AM3/15/19
to jenkinsc...@googlegroups.com

mail@daniel-spilker.com (JIRA)

unread,
Mar 22, 2019, 10:02:02 AM3/22/19
to jenkinsc...@googlegroups.com
Daniel Spilker updated Bug JENKINS-56580
 

All options are already supported by Dynamic DSL:

job('example') {
    publishers {
        jacoco {
            execPattern('**/wdl-util/**/target/**.exec')
            classPattern('**/wdl-util/**/target/classes')
            sourcePattern('**/wdl-util/**/src/main/java')
            sourceInclusionPattern('**/*.java')
            sourceExclusionPattern('')
            inclusionPattern('**/*.class')
            exclusionPattern('**/*Test*.class')
        }
    }
}
Change By: Daniel Spilker
Status: Open Fixed but Unreleased
Resolution: Not A Defect

cristalp@java.net (JIRA)

unread,
Apr 10, 2019, 8:52:07 AM4/10/19
to jenkinsc...@googlegroups.com
cristalp commented on Bug JENKINS-56580
 
Re: Configuration for JaCoCo plugin doesn't generate source inclusions

Well, I can't see it on https://jenkinsci.github.io/job-dsl-plugin/#path/mavenJob-publishers-jacocoCodeCoverage

When I try to use it with

      jacocoCodeCoverage {
        execPattern("**/${project}/**/target/**.exec")
        inclusionPattern("**/*.class")
        exclusionPattern("**/*Test*.class")
        classPattern("**/${project}/**/target/classes")
        sourcePattern("**/${project}/**/src/main/java")
        sourceInclusionPattern('**/*.java')
      }

I get

No signature of method: javaposse.jobdsl.dsl.helpers.publisher.JacocoContext.sourceInclusionPattern() is applicable for argument types: (java.lang.String) values: [**/*.java]

mail@daniel-spilker.com (JIRA)

unread,
Mar 11, 2020, 9:06:02 AM3/11/20
to jenkinsc...@googlegroups.com
Change By: Daniel Spilker
Status: Fixed but Unreleased Closed
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages