CircleCI 的 SonarCloud 错误:请检查属性 sonar.login 和 sonar.password

SonarCloud error from CircleCI: Please check the properties sonar.login and sonar.password

我正在尝试让 SonarCloud.io 与 CircleCI 一起工作。我有一个工作的 CircleCI 配置(SonarCloud 位除外)并且已按照 SonarCloud 中的设置说明进行操作。我的 CircleCI config.yml 看起来像这样:

version: 2.1

orbs:
  sonarcloud: sonarsource/sonarcloud@1.0.1

jobs:
  build:
    docker:
      - image: circleci/node:9.9

    working_directory: ~/repo

    steps:
      - checkout

      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run: npm install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: npm test            

      - run:
         name: Deploy circle-ci to Heroku Master
         command: |
           git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git +HEAD:master
      - sonarcloud/scan

workflows:
  main:
    jobs:
      - build:
          context: SonarCloud

我已将 sonar.projectKeysonar.organization 添加到 sonar-project.properties 并将 SONAR_TOKENSONAR_TEAMSONAR_PROJECT_KEY 添加到 CircleCI SonarCloud 上下文中我的团队。

当管道在 CircleCI 中运行时,我得到以下输出:

NFO: Scanner configuration file: /tmp/cache/scanner/sonar-scanner-4.1.0.1829-linux/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/circleci/repo/sonar-project.properties
INFO: SonarQube Scanner 4.1.0.1829
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Linux 4.15.0-1052-aws amd64
INFO: User cache: /tmp/cache/scanner/.sonar/cache
INFO: SonarQube server 8.0.0
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 3.271s
INFO: Final Memory: 5M/56M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: **Not authorized. Please check the properties sonar.login and sonar.password.**
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

Exited with code exit status 2

很多其他人似乎都遇到过这个问题,但 none 我看到的答案符合我的情况或有效。

正在查看要设置 sonar.login 的错误。您似乎依赖 SONAR_TOKEN,但根据 https://docs.sonarqube.org/latest/user-guide/user-token/,令牌应设置在 sonar.login。使用 sonar.login 的令牌不需要设置 sonar.password