How can I integrate SonarQube in my Gradle pipeline for Azure DevOps?

My pipeline is running fine with its Gradle task, as follows:

- task: Gradle@2
  displayName: 'Build Android'
  inputs:
    workingDirectory: '$(system.defaultWorkingDirectory)/android'
    gradleWrapperFile: '$(system.defaultWorkingDirectory)/android/gradlew'
    gradleOptions: '-Xmx3072m'
    options: 'clean'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
    tasks: 'assembleRelease'

Now, I’m trying to add SonarQube as shown below.

- task: SonarQubePrepare@4
  inputs:
    SonarQube: SonarQube
    scannerMode: 'Other'
    extraProperties: |
       sonar.projectKey=$(SONAR_PREFIX_KEY)-$(app-name):$(app-name)
       sonar.projectName=$(SONAR_PREFIX_KEY)-$(app-name):$(app-name)
       sonar.branch.name=$(Build.SourceBranchName)
       sonar.host.url=$(SONAR_HOST)
       sonar.login=$(SONAR_TOKEN)

- task: Gradle@2
        displayName: 'Build Android'
        inputs:
          gradleWrapperFile: '$(system.defaultWorkingDirectory)/android/gradlew'
          workingDirectory: '$(system.defaultWorkingDirectory)/android'
          options: 'clean'
          tasks: 'assembleRelease'
          publishJUnitResults: false
          javaHomeOption: 'JDKVersion'
          gradleOptions: '-Xmx3072m'
          sonarQubeRunAnalysis: true
          sqGradlePluginVersionChoice: 'specify'
          sonarQubeGradlePluginVersion: '2.6.1'
          checkStyleRunAnalysis: true
          findBugsRunAnalysis: false
          pmdRunAnalysis: true
          spotBugsAnalysis: false

- task: SonarQubePublish@4
  inputs:
    pollingTimeoutSec: '300'

When running the pipeline, I’m getting the following error.

Execution failed for task ':react-native-auth0:processDebugAndroidTestManifest'.
Error: The process '/Users/runner/work/1/s/android/gradlew' failed with exit code 1
    at ExecState._setResult (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.191.0/node_modules/azure-pipelines-task-lib/toolrunner.js:944:25)
    at ExecState.CheckComplete (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.191.0/node_modules/azure-pipelines-task-lib/toolrunner.js:927:18)
    at ChildProcess.<anonymous> (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.191.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)

Hi,

Welcome to the community!

This looks unrelated to analysis. Unless maybe there’s some sort of syntax error in the SonarQube task? I don’t know enough about Gradle to spot anything, but…

 
Ann

Hi @ganncamp thanks for your response. The build pipeline is running good without SonarQube tasks, but when I add the SonarQube tasks it fails with that error.