8

我也在stackoverflow上搜索了很多关于这个问题的信息,但我没有找到解决方案。

直到昨天,Travis 可以毫无问题地执行 sonar:sonar,但今天它不起作用,它给了我这个错误:

--- 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]

所以我改变了我的 SONAR_TOKEN 创建一个新的。但什么都没有改变。这是我的特拉维斯文件:

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

我真的不知道问题出在哪里。我也尝试生成一个新令牌并尝试直接使用它而不使用$SONAR_TOKEN,但没有任何改变。

提前谢谢你。

编辑这是将 -X 添加到我的 travis 命令后的完整错误:

[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]
4

1 回答 1

5

似乎您现在必须使用加密声纳令牌

travis encrypt

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

当令牌作为安全变量存储在 Travis 中时,它曾经在不加密令牌的情况下工作。

或者,如果您使用变量来存储未加密的令牌,则可以更改.travis.yml文件。

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

至:

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

这个解决方案对我有用。

于 2019-11-09T23:23:52.537 回答