将Travis CI与Sonarcloud结合使用时出错:未授权.请检查属性sonar.login和sonar.password [英] Error using Travis CI with Sonarcloud: Not authorized. Please check the properties sonar.login and sonar.password

查看:3213
本文介绍了将Travis CI与Sonarcloud结合使用时出错:未授权.请检查属性sonar.login和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进行自动化时,它会出现Not authorized. Please check the properties sonar.login and 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆