将 Travis CI 与 Sonarcloud 一起使用时出错:未授权.请检查属性 sonar.login 和 sonar.password [英] Error using Travis CI with Sonarcloud: Not authorized. Please check the properties sonar.login and sonar.password
问题描述
我正在按照 sonarcloud.io 上的 开始 说明执行 SonarQube 扫描仪我电脑上的 Maven:
I'm following Get started instructions on sonarcloud.io to execute the SonarQube Scanner for Maven from my computer:
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=ron190-github
-Dsonar.login=9...e
手动执行有效:
[INFO] ANALYSIS SUCCESSFUL, you can browse https://sonarcloud.io/dashboard/index
/jsql-injection:jsql-injection
但是当我准备使用 Travis CI 进行自动化时,它会因 未授权而失败.请检查属性 sonar.login 和 sonar.password.
:
But when I'm ready to automate with Travis CI it's failing with Not authorized. Please check the properties sonar.login and sonar.password.
:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar (default-cli) on project jsql-injection: Not authorized. Please check the properties sonar.login and sonar.password. -> [Help 1]
如果我将 sonar.login
添加到 mvn
命令,那么它就可以工作了:
And if I add sonar.login
to the mvn
command then it's working:
language: java
sudo: false
install: true
addons:
sonarcloud:
organization: "ron190-github"
token:
secure: "v...s="
jdk:
- oraclejdk8
script:
# JaCoCo is used to have code coverage, the agent has to be activated
# Not working
# - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.login=9...e
cache:
directories:
- '$HOME/.m2/repository'
- '$HOME/.sonar/cache'
我还使用了示例脚本.
你知道为什么 secure
令牌会被忽略,为什么默认配置会失败吗?
Do you know why secure
token is ignored and why it's failing with default config?
推荐答案
我同意 Santhosh Tpixler 你的问题是可能与令牌的 Travis 加密有关.就我而言,我需要 travis-ci.com
(与 travis-ci.org
相对,请参阅 https://devops.stackexchange.com/q/1201),因此必须使用 --pro
标志.
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>
这篇关于将 Travis CI 与 Sonarcloud 一起使用时出错:未授权.请检查属性 sonar.login 和 sonar.password的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!