7

I recently started using Travis CI and sonarqube in an open source project and have run into a problem with sonarqube-scanner.

My Travis CI page can be seen here: https://travis-ci.org/uglyoldbob/decompiler

My sonarqube page can be seen here: https://sonarqube.com/overview?id=uglyoldbob_decompiler

I'm running sonarqube-scanner on Travis CI it suddenly stopped working with the following error:

"ERROR: You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator."

I am using a token generated on sonarqube and have added it to the environment variables of Travis CI. I generated a new token when I noticed the problem and updated the environment variable with Travis but it did not change anything.

What can I do to fix this?

JJJ
  • 32,902
  • 20
  • 89
  • 102
uglyoldbob
  • 143
  • 1
  • 1
  • 9

7 Answers7

5

with mvn I had to pass to sonarcloud.io the parameter -Dsonar.branch=master

all command goes something like this:

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization={ORG_KEY} -Dsonar.login={GENERATED_KEY_ON_SONARCLOUD_SECURITY} -Dsonar.branch={BRANCH_NAME}

this fixed the following error:

You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator.

remember adding the analysis permission on the sonarcloud admin console.

Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49
4

In my case, it was a permission issue. Administration >> Security >> Global permission enter image description here

Piyush Sonigra
  • 1,423
  • 11
  • 10
2

"Chances are that the SonarCloud project key inferred from your Gradle configuration is already used by someone else" (Fabrice Bellingard at https://community.sonarsource.com/t/unauthorized-exception-on-first-sonarqube-analysis/333/2)

Choose a fix:

 -Dsonar.projectKey=$my_own_project_key

Or via build.gradle:

sonarqube {
    properties {
        property 'sonar.projectKey', '$my_own_project_key'
    }
}
aSemy
  • 5,485
  • 2
  • 25
  • 51
dr0i
  • 2,380
  • 2
  • 19
  • 36
0

In General: You need to pass a user token from an account with analysis permissions in your analysis parameters. Use the sonar.login property to do it.

Specifically: I see from your travis log that you are passing what looks like a user token in the sonar.login property. However you are passing it to sonar.host.url=http://nemo.sonarqube.org. You need to change this to https://sonarqube.com

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
0

We had a similar issue, caused by proxy configuration. Solved by adding the sonar server ip in nonProxyHost config in settings.xml

0

In my case I was entering a wrong key for the project

Rupali
  • 69
  • 7
-1

In my case, it was a firewall rule that was blocking the analysis file to upload, but this message is so generic it can be anything :(.

nick
  • 29
  • 8