我正在尝试让 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.projectKey
andsonar.organization
到sonar-project.properties
and SONAR_TOKEN
, SONAR_TEAM
andSONAR_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
很多其他人似乎都遇到过这个问题,但我所看到的答案都没有符合我的情况或没有奏效。