- ALM used (GitHub, Bitbucket Cloud, Azure DevOps): Azure DevOps
- CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI): Bitrise
- Languages of the repository: Java/Kotlin
We currently run Android app builds using Azure DevOps self-hosted agents. Our pipeline is running in Azure Pipelines and essentially consists of
- SonarCloud Prepare Analysis task
- Gradle build - using standard Android Gradle tasks + JaCoCo
- SonarCloud Run Code Analysis task
- SonarCloud Publish Quality Gate Result task
We are in the process of trying to migrate the Gradle build only to Bitrise. We will still have VCS and PRs in Azure DevOps, but the actual build will be run in Bitrise. An Azure Pipeline will be linked to the PR build, and this will trigger the Bitrise workflow and check the result.
We are a bit stuck on how to integrate with SonarCloud with the new setup. Some options we have considered are:
- Retain the “Prepare Analysis”, “Run Code Analysis” and “Publish Quality Gate Result” tasks on Azure DevOps, but using the output of the Gradle build which was run on Bitrise
- We are able to download artifacts from the Bitrise build into the Azure Pipeline working directory. But we are not sure which artifacts we would need to download in order to make the SonarCloud tasks work. I know we could say “just the entire contents of the build directory”. But to give some context, the build directory after a build is around 1.72GB in size as it includes a lot of intermediate artifacts that Sonar likely doesn’t use. We can see, for example from the logs, it is using /build/intermediates/classes/… - this directory is only 34MB in size. So that would be a huge difference. We don’t know if Sonar might use other directories but it is likely to be a lot less than the entire 1.72GB build directory
- Even if we could get this option to work, it is not ideal as we want to run Sonar through Bitrise if possible, hence the below two options
- Remove the SonarCloud tasks from Azure DevOps entirely, and run the SonarScanner directly from Bitrise, using the approach described at Other CIs | SonarQube Cloud | Sonar Documentation and SonarScanner for Gradle | SonarQube Cloud | Sonar Documentation
- It seems to assume that the SonarScanner will be directly integrated into the Gradle build, which is not the case currently. As I mentioned above, our Gradle build just uses standard Android build tasks + JaCoCo. I don’t know if we would have to refactor our Gradle build to use Sonar tasks in order to use this way
- Is it able to still publish PR comments to Azure DevOps? If so I am not sure how this is achieved as it’s not mentioned in the docs
- Similar to above but running the SonarScanner CLI directly in the Bitrise pipeline
- I am not sure if this is the closest equivalent to the Azure DevOps tasks we currently use. SonarScanner CLI | SonarQube Cloud | Sonar Documentation is saying “The SonarScanner CLI is the scanner to use when there is no specific scanner for your build system” which may not be exactly true as we are using Gradle. Having said that, when looking at the pipeline logs in Azure DevOps, I can see that internally it is indeed running the
sonar-scannerCLI command directly - Similarly to above, I am not sure how or if we could publish PR comments to Azure DevOps using this way
- I am not sure if this is the closest equivalent to the Azure DevOps tasks we currently use. SonarScanner CLI | SonarQube Cloud | Sonar Documentation is saying “The SonarScanner CLI is the scanner to use when there is no specific scanner for your build system” which may not be exactly true as we are using Gradle. Having said that, when looking at the pipeline logs in Azure DevOps, I can see that internally it is indeed running the