Azure-pipelines-tasks: Gradle v2 Jacoco code coverage is broken

Created on 29 Mar 2020  路  35Comments  路  Source: microsoft/azure-pipelines-tasks

Question, Bug, or Feature?
Type: Bug

Enter Task Name: Gradle v2

list here (V# not needed):
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

Environment

  • Server - Azure Pipelines

Pipeline: https://dev.azure.com/sis-cat-com/sis2-ws-all/_build/results?buildId=24337&view=results

  • Agent - Hosted :
    Windows 2019

Issue Description

When running a gradle.build with enabled code coverage the following error is thrown for jacoco:

Build file 'D:\a\1\s\build.gradle' line: 215

  • What went wrong:
    A problem occurred evaluating root project '*'.
    > Could not set unknown property 'append' for extension 'jacoco' of type org.gradle.testing.jacoco.plugins.JacocoTaskExtension.
ABTT Gradle bug

Most helpful comment

Hi @ebcFlagman @frenchf @glazzari @therottman @websolut @adsurg - the fix for this issue has been rolled out - I'm closing it at the moment, but please let us know if issue still appears

All 35 comments

I am seeing the same issue.. anyone has solution for this. Please update

I'm having the same problem. Please update

I have just tried this task on Azure Pipelines and getting the same error.

pipeline:

pool:
  vmImage: "ubuntu-latest"

steps:
  - task: Gradle@2
    inputs:
      gradleWrapperFile: '$(System.DefaultWorkingDirectory)/XXXXX/gradlew'
      workingDirectory: '$(System.DefaultWorkingDirectory)/XXXXX/'
      tasks: 'test'
      publishJUnitResults: true
      testResultsFiles: '**/TEST-*.xml'
      codeCoverageToolOption: 'JaCoCo'
      javaHomeOption: 'JDKVersion'
      jdkVersionOption: '1.11'
      sonarQubeRunAnalysis: false

the error message from build logs

BUILD SUCCESSFUL

.....


Could not set unknown property 'append' for extension 'jacoco' of type org.gradle.testing.jacoco.plugins.JacocoTaskExtension.

I have also confirmed that this Issue will reproduce.

  • This issue occurs when using Gradle 6.0 or higher and JDK 11.
  • It does not occur with Gradle 5.6.4 or lower and with JDK 1.8.
  • Therefore, this Issue is a Gradle and JDK version-dependent issue.

The following repositories do not generate an Issue, but the image of the code coverage is broken.
https://github.com/ryyaeg/pipelines-java

This is a gradle 6.0 issue append was removed and the task directly setting it

2020-06-08T16:17:08.1559398Z Task : Gradle
2020-06-08T16:17:08.1559637Z Description : Build using a Gradle wrapper script
2020-06-08T16:17:08.1559844Z Version : 2.163.2
2020-06-08T16:17:08.1560215Z Author : Microsoft Corporation
2020-06-08T16:17:08.1560682Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/gradle

I am seeing the same error:

2020-06-08T16:17:16.8973900Z Build file '/azp/agent/_work/2/s/build.gradle' line: 84
2020-06-08T16:17:16.8975209Z
2020-06-08T16:17:16.8975784Z * What went wrong:
2020-06-08T16:17:16.8976491Z A problem occurred evaluating root project 'services'.
2020-06-08T16:17:16.8977381Z > Could not set unknown property 'append' for extension 'jacoco' of type org.gradle.testing.jacoco.plugins.JacocoTaskExtension.

Locally, I am running Gradle 6.0.1 and jdk 8 (OpenJDK) without issue.

Still believe this is Azure-related as we only hit the issue when running on DevOps pipeline.
Is there a work around?

@kingwang-git It seems to be related to Gradle update. As mentioned here, the 'append' property on JacocoTaskExtension has been removed. Could you please share build.gradle and gradle.properties files of your project to make sure that there's no issue with Gradle version?

I'm having the same issue.

One workaround is to remove codeCoverageToolOption from the Gradle@2 task and add a new task after:

- task: PublishCodeCoverageResults@1
  inputs:
    codeCoverageTool: 'JaCoCo'
    summaryFileLocation: '$(Build.SourcesDirectory)/build/reports/jacoco/test/jacocoTestReport.xml'
    reportDirectory: '$(Build.SourcesDirectory)/build/reports/jacoco/test/html'

@therottman The solution to use PublishCodeCoverageResults task does not work because there is no generated file with code coverage statistics.

@ekaterina-tatanova hmn, maybe it's because I've this in build.gradle:

test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport // report is always generated after tests run
}

jacocoTestReport {
    dependsOn test // tests are required to run before generating the report
}

jacocoTestReport {
    reports {
        xml.enabled true
    }
}

I'm facing the same issue on Azure pipelines.

@glazzari What version of Gradle do you use? Could you please share build.gradle and gradle.properties files of your project?

@ekaterina-tatanova It's a Micronaut app created with mn create-app com.example.myapp --lang=kotlin --test=kotlintest. I downgraded gradle from 6.5.1 to 5.6.2 with OpenJDK 8 and it worked. Interesting, because the version with gradle 6.5.1 and OpenJDK 14 works on my laptop.

gradle.properties

micronautVersion=2.0.1
kotlinVersion=1.3.72

build.gradle - I've just added the following configs to the generated file.

jacocoTestCoverageVerification {
    violationRules {
        rule {
            limit {
                minimum = 0.25
            }
        }
    }
}

jacocoTestReport {
    reports {
        xml.enabled = true
        html.enabled = true
    }
}

check.dependsOn(jacocoTestReport)

I am having the same problem.
JDK 11
Gradle 6.5
Works fine locally but fails when run in Azure.
Based on all the above I think it's safe to say this is an Azure problem.
Any idea when this might be fixed?

I am having the same problem.
JDK 11
Gradle 6.0
Works fine locally but fails when run in Azure.

Hi @glazzari @frenchf @ebcFlagman could you please try to specify JDK version using JavaToolInstaller task and Gradle version in gradle-wrapper.properties file (distributionUrl property)?

@anatolybolshakov
I've defined the java version with the JavaToolInstaller to use Java 11 and in the gradle-wrapper.properties i've defined the url to the gradle 6 download. But I became the same error

Hi @ebcFlagman @frenchf @glazzari @therottman @websolut - thanks for provided info. We prepared a fix and going to deploy it soon, will let you know once it's deployed

Hi @ebcFlagman @frenchf @glazzari @therottman @websolut - thanks for provided info? We prepared a fix and going to deploy it soon, will let you know once it's deployed

Would you be kind enough to let me know too, please?

Hi @ebcFlagman @frenchf @glazzari @therottman @websolut @adsurg - the fix for this issue has been rolled out - I'm closing it at the moment, but please let us know if issue still appears

Hi @anatolybolshakov

I am still experiencing the issue getting the same error. We are using the following parameterisation in Gradle@2 Task:

codeCoverageTool: 'JaCoCo'
codeCoverageClassFilesDirectories: 'build/classes/java/main/'
codeCoverageFailIfEmpty: true

and the task utilised by the pipeline is:

Task : Gradle
Description : Build using a Gradle wrapper script
Version : 2.176.0

which as far as I could see is the task version which should contain the fix.

Nevertheless I get

Could not set unknown property 'append' for extension 'jacoco' of type org.gradle.testing.jacoco.plugins.JacocoTaskExtension

I have checked back and forth that our code is not setting the "append" anywhere and the build runs fine if I execute the jacocoTestReport task using gradle directly (in which case I don't get the helpful configuration defaults )

Same here, I've also still the issue

Task         : Gradle
Description  : Build using a Gradle wrapper script
Version      : 2.176.0

FAILURE: Build failed with an exception.

  • Where:
    Build file '/home/vsts/work/1/s/build.gradle' line: 155

  • What went wrong:
    A problem occurred evaluating root project 'coffeelink-master-data-service'.

    Could not set unknown property 'append' for extension 'jacoco' of type org.gradle.testing.jacoco.plugins.JacocoTaskExtension.

Hi @simsibimsiwimsi @ebcFlagman I can't reproduce it at the moment - could you please share your build.gradle file or provide minimal project - so we could reproduce it on our side?

I've uploaded the build.gradle and the pipeline script. When you need additional information please ask
The gradle version is 6.4

build.zip

Hi everyone, we just prepared a fix for another issue here and going to roll out these changes during next sprint

Hey @anatolybolshakov do you have any update on this?

Hi @glazzari we prepared a fix here and going to roll it out- usually it takes about 3 weeks to be done

Having the same issue. Following

Same here ! It's really blocking us for quality monitoring :(

Will you also update the task to supoport the new spotBugs parameter (previously "findBugs")?
In the yaml task it is called findBugsRunAnalysis.

@SqueedWalz could you please create a separate issue for it? It seems like an enhancement we could implement also

@anatolybolshakov Will do!

Hi @glazzari we prepared a fix here and going to roll it out- usually it takes about 3 weeks to be done

Any news on this @anatolybolshakov ?

Hi everyone! We have rolled out the fix for this issue - please let us know if it's still actual for you.

Closing this at the moment since we have rolled out the fix - please let us know if there are still any issues

Was this page helpful?
0 / 5 - 0 ratings