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

送分小仙女□ 提交于 2019-11-30 21:35:12

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'

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

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!