Azure Devops Gradle Pipeline -> 'Project was never analyzed. A regular analysis is required before a branch analysis.'

Hello everyone!

When building my project with the build pipeline on AzureDevops I get the above mentioned error.
To integrate sonarcloud I followed the guide at https://sonarcloud.io/documentation/integrations/vsts/

SonarCloud:
Organization and project was created, Token was generated for my user which is Administrator in the Organization and the Project.

AzureDevops:
Added the token as an external Service Connection.
Adapted my existing Gradle Pipeline:
Added “Prepare Analysis on SonarCloud” and adjusted the Gradle step.

I tried to first tried to “Cpecify version number” in gradle task to 2.8. This did not work, therefore I also tried to define it in the build.gradle as follows:
plugins {
id ‘checkstyle’
id ‘org.sonarqube’ version ‘2.8’
}

I could not find a way to trigger an initial analysis from the SonarCloud interface. I also build the master branch through the pipeline to trigger the “regular” analysis.

How do I get around this error?

Best Regards
Andreas

FYI
Here is the end of the log:

> Task :sonarqube FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonarqube'.
> Project was never analyzed. A regular analysis is required before a branch analysis.

* 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

BUILD FAILED in 5m 37s
42 actionable tasks: 42 executed
Error: The process '/home/vsts-buildagent/agent/_work/23/s/gradlew' failed with exit code 1
    at ExecState._setResult (/home/vsts-buildagent/agent/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.163.0/node_modules/azure-pipelines-task-lib/toolrunner.js:816:25)
    at ExecState.CheckComplete (/home/vsts-buildagent/agent/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.163.0/node_modules/azure-pipelines-task-lib/toolrunner.js:799:18)
    at ChildProcess.<anonymous> (/home/vsts-buildagent/agent/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.163.0/node_modules/azure-pipelines-task-lib/toolrunner.js:721:19)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:920:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
Result Attachments will be stored in LogStore
Run Attachments will be stored in LogStore
##[error]Error: The process '/home/vsts-buildagent/agent/_work/23/s/gradlew' failed with exit code 1

A regular analysis is required before a branch analysis.

Looks like before analyzing the branch you should analyze a main branch.

I have run the Pipeline for feature branches, but also the master branch and have always received the same message.

After your comment I then also tried the develop branch which is the base for all the feature branches, and it finally worked.
Thank you for the comment!