SonarCloud integration with Azure DevOps + Android Projects

Hi guys, this is my first post here then sorry if I dont post in correctly form but I will try.

So, I’m trying to create a CI pipeline in Azure DevOps to Android and when I use sonarqube into gradle task and I run this task, I’m getting the below error intermittently:

What went wrong:
Execution failed for task ‘:features:sonarqube’.

Fail to open plugin [securitypythonfrontend]: /home/vsts/.sonar/cache/262a3c6375ab0f28ad05aece3014d774/sonar-securitypythonfrontend-plugin.jar

This error shows a python plugin error but my project uses kotlin language, I was received other errors like go and cobol plugins.

This is my gradle task:

  • task: SonarCloudPrepare@1
    inputs:
    SonarCloud: ‘{I removed this value}’
    organization: ‘{I removed this value}’
    scannerMode: ‘Other’

  • task: Gradle@2
    inputs:
    gradleWrapperFile: ‘gradlew’
    tasks: ‘assembleDebug testDebugUnitTestCoverage’
    publishJUnitResults: true
    javaHomeOption: ‘JDKVersion’
    sonarQubeRunAnalysis: true
    sqGradlePluginVersionChoice: ‘build’

  • task: SonarCloudPublish@1
    inputs:
    pollingTimeoutSec: ‘300’

This is my sonarqube task in gradle file:

sonarqube {
properties {
property “sonar.sourceEncoding”, “UTF-8”
property “sonar.host.url”, “https://sonarcloud.io
property “sonar.login”, “{I removed this value}”
property “sonar.password”, “{I removed this value}”
property “sonar.projectName”, “{I removed this value}”
property “sonar.projectKey”, “{config.applicationId}" property "sonar.projectVersion", "{config.versionName}”
property “sonar.java.coveragePlugin”, “jacoco”
property “sonar.coverage.exclusions”, “/test/,/androidTest/,/R.class,/BuildConfig.,**/Manifest.,**/Test.,/com/example/databinding/*,/com/example/generated/callback/,**/Dto.,/android/databinding/*,/androidx/databinding/,**/di/module/,/MapperImpl.*,/BuildConfig.,**/Component.,/BR.*,/Manifest*.,**/Companion.,/Module.,/Dagger.,**/MembersInjector.,/Extensions.*,/InputMethodManagerLeaks.,**/_Factory*.,**/_ProvideFactory.*”
property “sonar.coverage.jacoco.xmlReportPaths”, “projectDir.path/build/reports/jacoco/test{config.buildVariant.capitalize()}UnitTestCoverage/test${config.buildVariant.capitalize()}UnitTestCoverage.xml”
}
}

Can you help me to discover if this is a problem with sonarqube plugin or azure devops when I integrate with sonarcloud?

Hi @Rennan and welcome to the community !

Is that possible for you to share the full log of the failing task, to get a bit more context ? I can PM you if you want to share it privately.

Thanks.

@mickaelcaro, thanks for your reply, I prefer to use PM, my project is a corporate application and I cannot post the log for everyone, I’ll wait for the PM.

Hi @mickaelcaro , @Rennan,

I have the exact same problem. Did you find a solution for this?

Thanks! :slight_smile:

Hi @eduardo.suarez

SonarQube gradle task cannot be run twice in parallel (for now at least), so you’ll have to make a choice, either run only one task for the whole build, or run for each module, but manage to run them “separately” (ie not in parallel )

HTH,
Mickaël

1 Like

Hi @mickaelcaro,

Thank you very much for the quick response and make the solution public! :slight_smile:

So is this some kind of a race condition problem or similar? Is there any plan to fix/improve this? I mean, being able to run tasks in parallel can shave a lot of CI time for big projects.

Thanks in advance!
Edu

Yes there are plan to improve this, but no ETA to give you unfortunately.

We use a shared cache across all instance on a single machine, so when 2 scans runs in parallel, there’s a chance that 2 plugins downloads collide each other, thus this error you might get.

Mickaël

Yeah, the problem makes a lot of sense.

One last question (promise heheh), is there any open issue where I can track progress on this?

Thanks so much!
Edu

1 Like

Hello @mickaelcaro, if we run the SonarQube gradle task “separately” by modules, we will need to create azure pipeline tasks manually to do this, this will cause a refactoring in our pipelines whenever we create a new module, I think you could analyze this problem for put the solution in the next version for us :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.