配置 SonarQube (Node.JS) 从内部服务器下载二进制文件

问题描述

我们试图做的是让 SonarQube 在 Docker 镜像上分析我们的 Typescript (Node.JS) 项目,但我们遇到了错误。如果有帮助,我们将尝试使用 Node.JS 中的 sonarqube-scanner 模块。

遇到的错误如下:

[17:57:23] Starting analysis...
[17:57:24] Getting info from "package.json" file
[17:57:24] Checking if executable exists: /root/.sonar/native-sonar-scanner/sonar-scanner-4.5.0.2216-linux/bin/sonar-scanner
[17:57:24] Could not find executable in "/root/.sonar/native-sonar-scanner".
[17:57:24] Proceed with download of the platform binaries for SonarScanner...
[17:57:24] Creating /root/.sonar/native-sonar-scanner
[17:57:24] Downloading from https://binaries.sonarsource.com/distribution/sonar-scanner-cli/sonar-scanner-cli-4.5.0.2216-linux.zip
[17:57:24] (executable will be saved in cache folder: /root/.sonar/native-sonar-scanner)
[91m[18:03:53] [0m[91mERROR: impossible to download and extract binary: connect ETIMEDOUT 91.134.125.245:443
[0m[91m[18:03:53] [0m[91m       SonarScanner binaries probably don't exist for your OS (linux).
[0m[91m[18:03:53]        In such situation,the best solution is to install the standard SonarScanner (requires a JVM).
[0m[91m[18:03:53]        Check it out at https://redirect.sonarsource.com/doc/install-configure-scanner.html

现在,如果您从错误中注意到,二进制文件服务器遇到了 ETIMEDOUT 错误,这是因为访问它的服务器来自无法访问外部站点的内部网络。

是否可以将 SonarQube 配置为从内部服务器拉取数据?如果是这样,我们将如何配置它?

非常感谢!

解决方法

我能够通过此处的 SonarQube Javascript 模块找到文档 (https://www.npmjs.com/package/sonarqube-scanner)

默认情况下,扫描仪二进制文件是从 https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/ 下载的。要使用自定义镜像,请设置 $SONAR_SCANNER_MIRROR。或使用 $SONAR_SCANNER_VERSION

下载精确版本

示例:

导出 SONAR_SCANNER_MIRROR=https://npm.taobao.org/mirrors/sonar-scanner/ 导出 SONAR_SCANNER_VERSION=3.2.0.1227

,

如果您想将 sonarqube 与 nodejs 集成以分析您的代码库以查找安全问题、代码异味或任何问题,本文将帮助您进行此集成并生成包含详细结果的报告。NodeJS and sonarqube integration with example>