Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarCloud error on Travis: Not authorized. Please check the properties sonar.login and sonar.password

I have search a lot about this problem also here on stackoverflow, but I didn't find the solution.

Until yesterday Travis could execute sonar:sonar without any problem, but today it doesn't work and it gives me this error:

--- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) @ progetto ---

    [INFO] User cache: /home/travis/.sonar/cache
    [INFO] SonarQube version: 8.0.0
    [INFO] Default locale: "en_US", source code encoding: "UTF-8"
    [INFO] Load global settings
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  04:38 min
    [INFO] Finished at: 2019-11-08T15:56:40Z
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project progetto: Not authorized. Please check the properties sonar.login and sonar.password. -> [Help 1]

so I change my SONAR_TOKEN creating a new one. But nothing changed. This is my Travis file:

language: java

jdk: openjdk8

env: DISPLAY=:99.0

services:
   - docker
   - xvfb
addons:
  sonarcloud:
    organization: "laviniadd"
    token:
         secure: $SONAR_TOKEN
install: true
cache:
   directories:
   - $HOME/.m2
   - $HOME/.sonar/cache

script:
 - git fetch --unshallow
 - mvn -f progetto/pom.xml clean verify -Pdocker -Pjacoco coveralls:report sonar:sonar

I really don't know where the problem is. I also try to generate a new token and try to use it directly without using $SONAR_TOKEN, but nothing changed.

Thank you in advanced.

EDIT This is the full error after adding -X to my travis command :

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project progetto: Unable to load component class org.sonar.scanner.bootstrap.ScannerPluginInstaller: Unable to load component class org.sonar.scanner.bootstrap.PluginFiles: Unable to load component class org.sonar.scanner.bootstrap.GlobalConfiguration: Unable to load component class org.sonar.scanner.bootstrap.GlobalServerSettings: Not authorized. Please check the properties sonar.login and sonar.password. -> [Help 1]
like image 676
Lulixter Avatar asked Nov 08 '19 16:11

Lulixter


1 Answers

Seems like you now must encrypt sonar token using

travis encrypt

https://docs.travis-ci.com/user/sonarcloud/

It used to work without encrypting token when the token was stored as secure variable in Travis.

Alternatively, if you're using a variable to store the token un-encrypted, you can change your .travis.yml file.

addons:
  sonarcloud:
    organization: utplsql
    token:
      # Put sonar connection token generated and encrypted.
      secure: ${SONAR_TOKEN}

To:

addons:
  sonarcloud:
    organization: utplsql
    token: ${SONAR_TOKEN}

This solution worked for me.

like image 199
jgebal Avatar answered Nov 20 '22 02:11

jgebal