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

Jacoco plugin does not read values from environment variables

    Details

    • Similar Issues:

      Description

      We have a requirement to pass the Jacoco plugin parameters during Jenkins Job execution so we are following the below setup.
      We are injecting the environment variable as below in build step in Jenkins job and using the same variables in Jacoco plugin (PFA screenshot) in post build action.

      pathToExecFiles="**/jacoco.exec"
      pathToClassDirectories="**/target/classes/main"
      pathToSourceDirectories="**/src/main/java"
      inclusions="*/.class"
      exclusions="**/Test.class"

      However the Jacoco plugin is not substituting the env variable as the same is working for other plugins (JUnit/testNG).

      The build is failing with below error.

      [JaCoCo plugin] Collecting JaCoCo coverage data...
      [JaCoCo plugin] $pathToExecFiles;$pathToClassDirectories;$pathToSourceDirectories; locations are configured
      [JaCoCo plugin] Number of found exec files for pattern $pathToExecFiles: 0
      [JaCoCo plugin] Saving matched execfiles:
      [JaCoCo plugin] Saving matched class directories for class-pattern: $pathToClassDirectories:
      [JaCoCo plugin] Saving matched source directories for source-pattern: $pathToSourceDirectories:
      [JaCoCo plugin] Loading inclusions files..
      [JaCoCo plugin] inclusions: [$inclusions]
      [JaCoCo plugin] exclusions: [$exclusions]
      ERROR: Build step failed with exception
      java.lang.IllegalStateException: basedir /app/jenkins/jobs/xxxxxx/builds/1/jacoco/classes does not exist

      Can you enable the Jacoco to read the env variable (if exist)?

      Thanks.
      Pawan

        Attachments

          Activity

          Hide
          pmv pmv added a comment -

          Can we also get the thresholds to read from the environment variables? That would allow us to manage all of our thresholds per repository in a properties file, and have an earlier step that reads the properties file and set the threshold.

          The use cases are similar, but let me know if you would like a separate ticket for this.

          Show
          pmv pmv added a comment - Can we also get the thresholds to read from the environment variables? That would allow us to manage all of our thresholds per repository in a properties file, and have an earlier step that reads the properties file and set the threshold. The use cases are similar, but let me know if you would like a separate ticket for this.
          Hide
          nongrate Arsenii Lisunov added a comment -

          Almost same issue, but two variables out of four are working correctly (no inclusions). Other two - not.

          JACOCO_EXEC_FILES_PATH="**/jacoco.exec"
          JACOCO_CLASS_FILES_PATH="**/target/classes/main"
          JACOCO_SOURCE_FILES_PATH="**/src/main/java"
          JACOCO_EXCLUSIONS="**/Test.class"

          JACOCO_EXEC_FILES_PATH is always changed to its value in in the JaCoCo configuration
          And both JACOCO_CLASS_FILES_PATH and JACOCO_SOURCE_FILES_PATH variables are parsed as strings:

          [JaCoCo plugin] **/jacoco.exec;$JACOCO_CLASS_FILES_PATH;$JACOCO_SOURCE_FILES_PATH; locations are configured
          [JaCoCo plugin] Number of found exec files for pattern **/jacoco.exec: ...
          [JaCoCo plugin] Saving matched class directories for class-pattern: $JACOCO_CLASS_FILES_PATH:
          [JaCoCo plugin] Saving matched source directories for source-pattern: $JACOCO_SOURCE_FILES_PATH:
          [JaCoCo plugin] inclusions: []
          [JaCoCo plugin] exclusions: [**/Test.class]

          Show
          nongrate Arsenii Lisunov added a comment - Almost same issue, but two variables out of four are working correctly (no inclusions). Other two - not. JACOCO_EXEC_FILES_PATH="**/jacoco.exec" JACOCO_CLASS_FILES_PATH="**/target/classes/main" JACOCO_SOURCE_FILES_PATH="**/src/main/java" JACOCO_EXCLUSIONS="**/Test.class" JACOCO_EXEC_FILES_PATH is always changed to its value in in the JaCoCo configuration And both JACOCO_CLASS_FILES_PATH and JACOCO_SOURCE_FILES_PATH variables are parsed as strings: [JaCoCo plugin] **/jacoco.exec;$JACOCO_CLASS_FILES_PATH;$JACOCO_SOURCE_FILES_PATH; locations are configured [JaCoCo plugin] Number of found exec files for pattern **/jacoco.exec: ... [JaCoCo plugin] Saving matched class directories for class-pattern: $JACOCO_CLASS_FILES_PATH: [JaCoCo plugin] Saving matched source directories for source-pattern: $JACOCO_SOURCE_FILES_PATH: [JaCoCo plugin] inclusions: [] [JaCoCo plugin] exclusions: [**/Test.class]
          Hide
          nongrate Arsenii Lisunov added a comment -

          So, here's the pull request for the functionality:
          https://github.com/jenkinsci/jacoco-plugin/pull/77

          Show
          nongrate Arsenii Lisunov added a comment - So, here's the pull request for the functionality: https://github.com/jenkinsci/jacoco-plugin/pull/77
          Hide
          rashmi_g Rashmi G added a comment -

          I've run into the same issue described by Pawan and Arsenii. Why hasn't the PR been merged yet?

          Show
          rashmi_g Rashmi G added a comment - I've run into the same issue described by Pawan and Arsenii. Why hasn't the PR been merged yet?
          Hide
          centic centic added a comment -

          Because this is open source and there is nobody paid here. So if you need this to be accelerated you need to step in yourself and apply on the jenkins-mailing-list to get rights to contribute the plugin.

          Show
          centic centic added a comment - Because this is open source and there is nobody paid here. So if you need this to be accelerated you need to step in yourself and apply on the jenkins-mailing-list to get rights to contribute the plugin.
          Hide
          newplay123 Xin Zhao added a comment -

          Almost same issue , jacoco plugin 3.0.4 also does not read value from parameterized build

          Inclusions,Exclusions is available ,but the others is not .

          Show
          newplay123 Xin Zhao added a comment - Almost same issue , jacoco plugin 3.0.4 also does not read value from parameterized build Inclusions,Exclusions is available ,but the others is not .

            People

            • Assignee:
              ognjenb Ognjen Bubalo
              Reporter:
              pawanonline85 Pawan Gupta
            • Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: