3

I try to configure code analyzing, using sonarcube on an azure pipeline. When I run the pipeline I got errors like this.

Error: "Type 'org.sonarqube.gradle.SonarQubeTask' property 'pluginVersion' is private and annotated with @Internal."

Task:sonarqube FAILED
WARNING:API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed in version 7.0 of the Android Gradle plugin.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':sonarqube' (type 'SonarQubeTask').
  - Type 'org.sonarqube.gradle.SonarQubeTask' property 'pluginVersion' is private and annotated with @Internal.
    
    Reason: Annotations on private getters are ignored.
    
    Possible solutions:
      1. Make the getter public.
      2. Annotate the public version of the getter.
    
    Please refer to https://docs.gradle.org/7.0.2/userguide/validation_problems.html#private_getter_must_not_be_annotated for more details about this problem.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 6m 34s
78 actionable tasks: 78 executed
ShadowUC
  • 724
  • 6
  • 19

3 Answers3

6

At the time of making the build I encounter below issue.

Type 'org.sonarqube.gradle.SonarQubeTask' property 'pluginVersion' is private and annotated with @Internal

The above bug come when you are using latest version of gradle(7.x) and old version of sonarqube-gradle-plugin

To fix the bug please use 3.3 version sonarqube-gradle-plugin

Please use below line at the project level build.gradle:

classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3'

2

The "Code Analysis" comes from extension maintained by sonarqube, there is a same query on the community, you can comment and monitor on it.

In addition, you can try downgrade to Gradle 4.0 to check if it's a compatible issue.

wade zhou - MSFT
  • 1,397
  • 1
  • 3
  • 6
2

Add these lines on your .yml file:

task: Gradle@2
displayName: 'gradlew build'
inputs:
  (...)
  tasks: 'build'
  sonarQubeRunAnalysis: true
  sqGradlePluginVersionChoice: 'specify'
  sonarQubeGradlePluginVersion: '3.3'

Source: https://learn.microsoft.com/fr-fr/azure/devops/pipelines/tasks/build/gradle?view=azure-devops

Asue
  • 1,501
  • 1
  • 13
  • 22