Problems when caching sonar in Bitbucket Pipelines

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

Anyone able to assist with this problem?

Hi @jgreyling,

We are looking at your issue and we need some more time to investigate.

We will come back to you with more information.

Hi Fan,

thank you! Please let me know once you have any feedback or need more debugging information.

@Fan_Yang any news on this perhaps?

Hi @jgreyling,

Our dev team is still working on it. They will update here with more information.

Hey @jgreyling,

I am trying to reproduce the problem.

Would you be able to run the analysis with the following parameters: ./gradlew build sonarqube -Dsonar.verbose=true --info ?

I will create a private thread so you can share with me the logs.

Best,
Marcin

Thanks, I’ve responded in the private thread.