React Native on Azure Devops with SonarCloud Analysis

Hi,

  • CI system used ( Azure DevOps )

*React Native for Android App

An app which builds and creates apk normally, DOES NOT SO when SonarCloud tasks are introduced and SonarQubeAnalysis is made TRUE. The Gradle task does not pass; I get an error which reads: “Execution failed for task ':react-native-keychain:processDebugUnitTestManifest”
I have tried many workarounds that are circulating in the internet , but to no avail.
Has anyone faced a a similar problem but solved in the end?
Best regards

Hey there.

Would it be possible for you to provide a small reproducer?

Hi Colin,

Thank you very much for your reply. I will post the error page that I end up with asap.

Fevzi

@
Here are the lines from my pipelines:
trigger:
- none

pool:
  vmImage: ubuntu-latest

variables:
  - group: android-variables
  
steps:
 
- task: NodeTool@0
  displayName: 'Install Node'
  inputs:
    versionSpec:  '16.x'    

- script: npm install
  workingDirectory: src
  displayName: 'Install node dependencies'

- task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@1
  displayName: 'Prepare analysis on SonarCloud'
  inputs:
    SonarCloud: 'sonar cloud'
    organization: xxxxxxx'
    projectKey: xxxApp
    projectName: POS
    scannerMode: Other
    extraProperties: | 
      sonar.pullrequest.provider=Azure DevOps Services
      sonar.pullrequest.vsts.token.secured=$(sonarVstsToken)
      sonar.exclusions=node_modules/** 
- task: Gradle@3
  inputs:
    workingDirectory: 'android/'
    gradleWrapperFile: 'android/gradlew'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.11'
    gradleOptions: '-Xmx3072m'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
    # tasks: 'assembleRelease'
    sonarQubeRunAnalysis: true
    tasks: 'assembleStagRelease'
    
#- task: SonarSource.sonarcloud.ce096e50-6155-4de8-8800-4221aaeed4a1.SonarCloudAnalyze@1
#  displayName: 'Run Code Analysis'
  
- task: SonarSource.sonarcloud.38b27399-a642-40af-bb7d-9971f69712e8.SonarCloudPublish@1
  displayName: 'Publish Quality Gate Result'


- task: AndroidSigning@3
  inputs:
   apkFiles: '**/*.apk'
   apksign: true
   apksignerKeystoreFile: '$(keystore.file)'
   apksignerKeystorePassword: '$(storePassword)'
   apksignerKeystoreAlias: '$(key.alias)'
   apksignerKeyPassword: '$(keyPassword)'
   apksignerArguments: '--out  $(Build.SourcesDirectory)/android/app/build/outputs/apk/stag/release/ ceppos-app.release.apk'


The error output:
> Task :react-native-keychain:mergeDebugUnitTestResources

w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':react-native-keychain:processDebugUnitTestManifest'.

> Manifest merger failed with multiple errors, see logs

* 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](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.3.3/userguide/command_line_interface.html#sec:command_line_warnings

Execution optimizations have been disabled for 20 invalid unit(s) of work during this build to ensure correctness.

Please consult deprecation warnings for more details.

1335 actionable tasks: 1335 executed

BUILD FAILED in 8m 52s

Error: The process '/home/vsts/work/1/s/***/gradlew' failed with exit code 1

at ExecState._setResult (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/3.208.0/node_modules/azure-pipelines-task-lib/toolrunner.js:944:25)

at ExecState.CheckComplete (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/3.208.0/node_modules/azure-pipelines-task-lib/toolrunner.js:927:18)

at ChildProcess.<anonymous> (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/3.208.0/node_modules/azure-pipelines-task-lib/toolrunner.js:840:19)

at ChildProcess.emit (events.js:198:13)

at maybeClose (internal/child_process.js:982:16)

at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

##[error]Code analysis failed. Gradle exit code: -1. Error: Error: The process '/home/vsts/work/1/s/***/gradlew' failed with exit code 1

The pipeline works without any problem and creates the required apk when  SonarQubeRunAnalysis parameter is false. When I turn it on, the build fails.  I read in this site that when that parameter is true, we should remove the analysis task section, which I did as you can see. 
Thank you very much in advance for a possible solution.
Fevzi Ozgul

Hello @fozgul ,

Thanks for showing your pipeline steps. Two requests:

  1. Please remove the following extraProperties:
      sonar.pullrequest.provider=Azure DevOps Services
      sonar.pullrequest.vsts.token.secured=$(sonarVstsToken)

You should not need to set these two parameters at all. Please remove them or please explain why you need to set them.
2. Can you please enable DEBUG logs by appending -d to the Gradle tasks?

        ...
        sonarQubeRunAnalysis: true
        tasks: 'assembleStagRelease -d'

Then attach the logs here with your Azure pipeline yaml for me to review.

If you prefer to share this information privately, let me know and we can start a private thread.