Error using Travis CI with Sonarcloud: Not authorized. Please check the properties sonar.login and sonar.password

后端 未结 3 1413
迷失自我
迷失自我 2021-01-05 12:52

I\'m following Get started instructions on sonarcloud.io to execute the SonarQube Scanner for Maven from my computer:



        
相关标签:
3条回答
  • 2021-01-05 13:33

    I agree with Santhosh Tpixler that your problem is likely with the Travis encryption of the token. In my case I need travis-ci.com (opposed to travis-ci.org, see https://devops.stackexchange.com/q/1201), therefore had to use the --pro flag.

    From inside the project directory I used these commands:

    travis login --pro
    travis encrypt --pro <your-hexadecimal-token>
    
    0 讨论(0)
  • 2021-01-05 13:34

    It seems that the tag secure is not working, use a repo variable instead:

    language: java
    sudo: false
    install: true
    
    addons:
      sonarcloud:
        organization: "ron190-github"
    
    jdk:
      - oraclejdk8
    
    script:
      # JaCoCo is used to have code coverage, the agent has to be activated
      - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.login=${SONAR_TOKEN}
    
    cache:
      directories:
        - '$HOME/.m2/repository'
        - '$HOME/.sonar/cache'
    
    0 讨论(0)
  • 2021-01-05 13:45

    The problem is with the travis encryption.

    Correct encryption syntax:

    travis encrypt 309473973909Z09R830 -r my-org/my-repo

    No variable name, no quote.

    If you are running travis encrypt inside your repo directory you can just use

    travis encrypt 309473973909Z09R830

    Kindly replace you token for 309473973909Z09R830

    The above trick worked for me. Thought of making it more visible to the public.

    Credits: @ron190

    0 讨论(0)
提交回复
热议问题