SonarCloud Analysis is failing in Azure DevOps pipeline with Gradlew build

  1. SonarQube scanner for Gradle plugin version ----------> 2.6.1

  2. error observed ------> Validation of project reactor failed:
    o “Customer App” is not a valid project or module key. It cannot be empty nor contain whitespaces.
    o “Customer App:app” is not a valid project or module key. It cannot be empty nor SonarQube scanner

  3. steps to reproduce ----------->
    a) I have configured the SonarQube scanner in DevOps pipeline using gradlew build.
    b) Run the pipeline. Getting above mentioned error.

The error message is pretty self-explanatory, isn’t it?

You can’t have any whitespace in your SonarCloud project key. So just change it to “customerapp” or something like that.

It would also help if you could share your azure-pipelines.yml.

Cheers,
Robin

I am using the classic editor to create a pipeline without YAML.

Using following plugin

  1. Prepare Analysis Configuration

steps:

  • task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@1
    displayName: ‘Prepare analysis on SonarCloud’
    inputs:
    SonarCloud: SonarCloudPfg
    organization: pfg
    scannerMode: Other
  1. Gradle ( gradlew build)

steps:

  • task: Gradle@2
    displayName: ‘gradlew build’
    inputs:
    gradleWrapperFile: ‘(Parameters.wrapperScript)' tasks: '(Parameters.tasks)’
    sonarQubeRunAnalysis: true
1 Like

According to this link the Sonar project key defaults to [{project.group}:]{project.name} with Gradle, so you probably should take a look at that or set the project key manually yourself.