Hi,
We’ve implemented SonarScanner for Gradle in our Java project. As part of our CI process (Bitbucket Pipelines) we’re trying to cache the output as per the official documentation:
definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
When we run the pipeline the first time it works perfectly fine. However when we run it a second time, the Gradle task fails with:
+ ./gradlew sonarqube
Starting a Gradle Daemon (subsequent builds will be faster)
> Configure project :
Configured recognizedBranch: develop
Configured publishVersion: 3.0.develop8
Configured latestBranchVersion: 3.0.develop+
Configured commonsVersion: 3.0.develop+
> Task :compileJava
Note: Generating OpenAPI Documentation
Note: Writing OpenAPI YAML to destination: /opt/atlassian/pipelines/agent/build/build/classes/java/main/META-INF/swagger/feeds-1.0.0.yml
Note: Writing OpenAPI View to destination: /opt/atlassian/pipelines/agent/build/build/classes/java/main/META-INF/swagger/views/swagger-ui/index.html
Note: Creating bean classes for 206 type elements
Note: Creating bean classes for 4 type elements
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> Task :compileGroovy NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes
> Task :compileTestJava
Note: Creating bean classes for 7 type elements
> Task :sonarqube FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sonarqube'.
> Unable to register extension com.sonar.security.frontend.python.A from plugin 'securitypythonfrontend'
* 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.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings
4 actionable tasks: 3 executed, 1 up-to-date
BUILD FAILED in 46s
Once we clear the cache from Bitbucket Pipelines it works again. For now we have to disable this feature. Any idea what is going on?
Btw. here is a successful run for comparison.
+ ./gradlew sonarqube
+ printf '\n'
+ printf '\x1d+ ./gradlew sonarqube\n'
+ ./gradlew sonarqube
Starting a Gradle Daemon (subsequent builds will be faster)
> Configure project :
Configured recognizedBranch: develop
Configured publishVersion: 3.0.develop9
Configured latestBranchVersion: 3.0.develop+
Configured commonsVersion: 3.0.develop+
> Task :compileJava
Note: Generating OpenAPI Documentation
Note: Writing OpenAPI YAML to destination: /opt/atlassian/pipelines/agent/build/build/classes/java/main/META-INF/swagger/feeds-1.0.0.yml
Note: Writing OpenAPI View to destination: /opt/atlassian/pipelines/agent/build/build/classes/java/main/META-INF/swagger/views/swagger-ui/index.html
Note: Creating bean classes for 206 type elements
Note: Creating bean classes for 4 type elements
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> Task :compileGroovy NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes
> Task :compileTestJava
Note: Creating bean classes for 7 type elements
> Task :sonarqube
Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
Use of preview features have been detected during analysis. Enable DEBUG mode to see them.
Use of preview features have been detected during analysis. Enable DEBUG mode to see them.
The Data Dictionary is not configured for PLSQL analyzer which prevents rule(s) S3641, S3921, S3618, S3651 to raise issues. See https://sonarcloud.io/documentation/analysis/languages/plsql/
Invalid character encountered in file /opt/atlassian/pipelines/agent/build/src/test/resources/mappings/onecart/v2_woolworths_categories.json at line 23 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 3m 45s
4 actionable tasks: 3 executed, 1 up-to-date