Jacoco report generating throwing exception

I have a command in Teamcity to generate jacoo report, like the following.

##teamcity[jacocoReport dataPath='jacoco.exec' includes='com.package.core.*' classpath='/intermediates/classes/debug/**']
 But I am getting an illegalStateException
java.lang.IllegalStateException: External scan (outside of basedir) is not allowed
    at jetbrains.buildServer.util.pathMatcher.DirectoryScanner.normalizePatterns(DirectoryScanner.java:173)
    at jetbrains.buildServer.util.pathMatcher.DirectoryScanner.<init>(DirectoryScanner.java:127)
    at jetbrains.buildServer.util.pathMatcher.AntPatternFileCollector.scanDir(AntPatternFileCollector.java:149)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.analyzeClassPath(JacocoReportBuilder.java:233)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.getCoverageBundle(JacocoReportBuilder.java:180)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.generateReport(JacocoReportBuilder.java:100)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.main(JacocoReportBuilder.java:40)

 This is the content of my Jacoco.log file.
 
Jacoco report builder run with arguments: [-dataPaths, ' /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/build/jacoco/testDebugUnitTest.exec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/build/outputs/code-coverage/connected/VirtualBox - 6.0.1-coverage.ec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/build/jacoco/testDebugUnitTest.exec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/build/outputs/code-coverage/connected/VirtualBox - 6.0.1-coverage.ec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/build/jacoco/testDebugUnitTest.exec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/build/outputs/code-coverage/connected/VirtualBox - 6.0.1-coverage.ec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/build/jacoco/testDebugUnitTest.exec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/build/outputs/code-coverage/connected/VirtualBox - 6.0.1-coverage.ec', -sr, ' /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/src/main/java /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/src/main/java /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/src/main/java /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/src/main/java', -cp, ' projectOne/intermediates/classes/debug/** projectTwo/intermediates/classes/debug/** app/intermediates/classes/debug/** projectThree/intermediates/classes/debug/**', -i, 'com.example.ui* com.example.common* com.example.wrapper* com.example.security*', -e, '**/R.class **/R$*.class com.example.ui.test* com.example.security.test* com.example.common.test* *Test* *test* **/*Test*.* android/**/*.* **/*$ViewInjector*.* **/BuildConfig.* **/Manifest*.*', -rd, '/home/example/TeamCity/buildAgent/temp/buildTmp/JACOCO3729887702043009945coverage/report', -t, 'Android', -l, 'true']
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/build/jacoco/testDebugUnitTest.exec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/build/jacoco/testDebugUnitTest.exec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/build/jacoco/testDebugUnitTest.exec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/build/jacoco/testDebugUnitTest.exec
Exec files loaded in: 97
Filter set up with includes: [com.example.ui*, com.example.common*, com.example.wrapper*, com.example.security*]; excludes: [**/R.class, **/R$*.class, com.example.ui.test*, com.example.security.test*, com.example.common.test*, *Test*, *test*, **/*Test*.*, android/**/*.*, **/*$ViewInjector*.*, **/BuildConfig.*, **/Manifest*.*]
java.lang.IllegalStateException: External scan (outside of basedir) is not allowed
    at jetbrains.buildServer.util.pathMatcher.DirectoryScanner.normalizePatterns(DirectoryScanner.java:173)
    at jetbrains.buildServer.util.pathMatcher.DirectoryScanner.<init>(DirectoryScanner.java:127)
    at jetbrains.buildServer.util.pathMatcher.AntPatternFileCollector.scanDir(AntPatternFileCollector.java:149)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.analyzeClassPath(JacocoReportBuilder.java:233)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.getCoverageBundle(JacocoReportBuilder.java:180)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.generateReport(JacocoReportBuilder.java:100)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.main(JacocoReportBuilder.java:40)

 
 
 
0
14 comments

You are starting the classpath with a "/", which indicates a full path. Our jacoco only supports relative paths there, which is the message the exception is trying to show, so removing the starting "/" should be enough for it to work. Could you give that a try?

0

Thanks for the reply. If I understand it correctly this is my class path right ?

-cp, ' projectOne/intermediates/classes/debug/** projectTwo/intermediates/classes/debug/** app/intermediates/classes/debug/** projectThree/intermediates/classes/debug/**'


I don't see any "/" in front of it. Can you be more specific.

0

Hi Johny,

sorry, the "/" is included in the service message you wrote as the first line

##teamcity[jacocoReport dataPath='jacoco.exec' includes='com.package.core.*' classpath='/intermediates/classes/debug/**']

and reading the exception I didn't really try to check the full command. As you can see there, your classpath starts with a "/", but I'm not fully sure why it doesn't show like that at the command.

I can suggest removing the "/" from the start of the classpath value on the service message unless it was a typo and it isn't really there. I'm fairly confident this would be the root of the issue as it's also consistent with the error message, but I'm going to pass this along to understand why the command passed to jacoco looks different (and doesn't contain) what was passed as classpath

0
##teamcity[jacocoReport dataPath='jacoco.exec' includes='com.package.core.*' classpath='/intermediates/classes/debug/**']

This I just put in to show a sample. The command that i give in the gradle file is quite big. I will try with the relative paths and get back to you.

0

Hello

The problem occurs because of a blank space in the begin of the classpath argument. I'll fix this error and as a workaround you can remove it from the service message. Also check the dataPath argument - you've probably forgot to escape spaces in paths to .ec files ('VirtualBox - 6.0.1-coverage.ec'). 

0
Jacoco report builder run with arguments: [-dataPaths, '/home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/build/jacoco/testDebugUnitTest.exec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/build/outputs/code-coverage/connected/VirtualBox\ -\ 6.0.1-coverage.ec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/build/jacoco/testDebugUnitTest.exec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/build/outputs/code-coverage/connected/VirtualBox\ -\ 6.0.1-coverage.ec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/build/jacoco/testDebugUnitTest.exec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/build/outputs/code-coverage/connected/VirtualBox\ -\ 6.0.1-coverage.ec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/build/jacoco/testDebugUnitTest.exec /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/build/outputs/code-coverage/connected/VirtualBox\ -\ 6.0.1-coverage.ec', -sr, '/home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/src/main/java /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/src/main/java /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/src/main/java /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/src/main/java', -cp, '/home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/build/intermediates/classes/debug/** /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/build/intermediates/classes/debug/**/*.class /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/build/intermediates/classes/debug/** /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/build/intermediates/classes/debug/**/*.class /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/build/intermediates/classes/debug/** /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/build/intermediates/classes/debug/**/*.class /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/build/intermediates/classes/debug/** /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/build/intermediates/classes/debug/**/*.class', -i, 'com.example.ui* com.example.common* com.example.wrapper* com.example.security*', -e, '**/R.class **/R$*.class com.projectOne.ui.test* com.projectTwo.security.test* com.projectTwo.common.test* *Test* *test* **/*Test*.* android/**/*.* **/*$ViewInjector*.* **/BuildConfig.* **/Manifest*.*', -rd, '/home/example/TeamCity/buildAgent/temp/buildTmp/JACOCO8986781811021654212coverage/report', -t, 'Android', -l, 'true']
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/build/jacoco/testDebugUnitTest.exec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectOne/build/outputs/code-coverage/connected/VirtualBox - 6.0.1-coverage.ec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/build/jacoco/testDebugUnitTest.exec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectTwo/build/outputs/code-coverage/connected/VirtualBox - 6.0.1-coverage.ec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/build/jacoco/testDebugUnitTest.exec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/projectThree/build/outputs/code-coverage/connected/VirtualBox - 6.0.1-coverage.ec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/build/jacoco/testDebugUnitTest.exec
Reading data from /home/example/TeamCity/buildAgent/work/a7d4d4b5be4f2944/app/build/outputs/code-coverage/connected/VirtualBox - 6.0.1-coverage.ec
Exec files loaded in: 189
Filter set up with includes: [com.example.ui*, com.example.common*, com.example.wrapper*, com.example.security*]; excludes: [**/R.class, **/R$*.class, com.example.ui.test*, com.example.security.test*, com.example.common.test*, *Test*, *test*, **/*Test*.*, android/**/*.*, **/*$ViewInjector*.*, **/BuildConfig.*, **/Manifest*.*]
java.lang.IllegalStateException: External scan (outside of basedir) is not allowed
    at jetbrains.buildServer.util.pathMatcher.DirectoryScanner.normalizePatterns(DirectoryScanner.java:173)
    at jetbrains.buildServer.util.pathMatcher.DirectoryScanner.<init>(DirectoryScanner.java:127)
    at jetbrains.buildServer.util.pathMatcher.AntPatternFileCollector.scanDir(AntPatternFileCollector.java:149)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.analyzeClassPath(JacocoReportBuilder.java:233)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.getCoverageBundle(JacocoReportBuilder.java:180)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.generateReport(JacocoReportBuilder.java:100)
    at jetbrains.buildServer.coverage.jacoco.JacocoReportBuilder.main(JacocoReportBuilder.java:40)

Thanks for the reply. I gave the escape characters for the .ec files and removed the spaces from the beginning of the class path. But I still have the exception. Attaching the log file again

0

Please try to use relative paths in classpath argument

0

It worked. Thanks for the prompt and fast support. :-)

0

Sorry am Bit late to this topic..

where are you providing the service message in the TeamCity Configuration? Command Line Step?

Am new to TeamCity and trying to get a coverage thru command line....

##teamcity[jacocoReport dataPath='report/*.exec' classpath='/src' reportDir='temp/jacocoReport']

i used the following command .. i don't see any error / related message .. any help please

 

 

0

Hi Harissh,

 

The way to pass service messages to teamcity is pushing those messages into the log text, where teamcity will pick them up and process them as required. Usually, this is done via a command line with an "echo" command that simply outputs it, but any other kind of build script that can post the line to the command line would work.

 

If you just add the line without an echo or similar, "#" lines are usually considered comments by most scripting languages and thus ignored, making it impossible for teamcity to pick it up. More information on service messages here: https://confluence.jetbrains.com/display/TCD18/Build+Script+Interaction+with+TeamCity

0

thanks Denis, here is the output i get upon adding the following line

echo "##teamcity[jacocoReport dataPath='report/jacoco.exec' classpath='scratch/TeamCity/%build.number%/src']"

[Step 7/8] Generating JaCoCo coverage...
[07:46:06][Generating JaCoCo coverage...] JaCoCo report generation failed. Exit code: 2
[07:46:06][Step 7/8] Publishing JaCoCo coverage...
[07:46:06][Publishing JaCoCo coverage...] Publishing artifacts (2m:04s)
[07:46:06][Publishing artifacts] Collecting files to publish: [/data/buildAgent/bin/jacoco.log=>.teamcity/coverage_jacoco]
[07:48:11][Publishing artifacts] Publishing 1 file using [ArtifactsCachePublisher]: /data/buildAgent/bin/jacoco.log => .teamcity/coverage_jacoco
[07:48:11][Publishing artifacts] Publishing 1 file using [WebPublisher]: /data/buildAgent/bin/jacoco.log => .teamcity/coverage_jacoco
[07:46:06][Publishing JaCoCo coverage...] Publishing artifacts (2m:04s)
[07:46:06][Publishing artifacts] Collecting files to publish: [/data/buildAgent/temp/buildTmp/JACOCO886428498494759978coverage/coverage.params=>.teamcity/coverage_jacoco]
[07:48:11][Publishing artifacts] Publishing 1 file using [ArtifactsCachePublisher]: /data/buildAgent/temp/buildTmp/JACOCO886428498494759978coverage/coverage.params => .teamcity/coverage_jacoco
[07:48:11][Publishing artifacts] Publishing 1 file using [WebPublisher]: /data/buildAgent/temp/buildTmp/JACOCO886428498494759978coverage/coverage.params => .teamcity/coverage_jacoco
0

on an another try i added a Build Step with Gradle and selected Jacoco Covergae

and trying to point to the .exec that i moved to TeamCity Agent from a external VM.. i still see the TeamCity point to a exec file generated by itself..

help me understand how do i make the TeamCity to consider file 'exec' file.. or is there any variable that can point to the current location of the jacoco.exec file? which i can use it to copy to that location..

0

Hi Denis,

 

  i got it working.. Thanks for the solution.. the relative path was not right so it was giving some error.. now its generating the report ...

 

Thanks again

 

 

0

Hi Gautam...Can you share your email, i have few doubts on teamcity and new to teamcity, hope you share  me.

 

Thank you.

0

Please sign in to leave a comment.