Flo*_*n F 5 azure-devops sonarcloud
我有一个包含 Javascript 和 Typescript 文件的项目。我正在使用 SonarCloud 从 Azure DevOps 管道分析这个项目。
我在构建管道中设置任务“准备分析配置”,如下所示:
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'Sonarcloud'
organization: 'MyOrg'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'My key'
cliProjectName: 'My name'
cliSources: '.'
Run Code Online (Sandbox Code Playgroud)
运行管道时,我的管道在Sonar Cloud Analysis步骤中出现以下错误
INFO: Found 1 tsconfig.json file(s): [/home/vsts/work/1/s/tsconfig.json]
##[error]ERROR: Cannot find module 'typescript'
##[error]ERROR: TypeScript dependency was not found and it is required for analysis.
ERROR: Install TypeScript in the project directory or use NODE_PATH env. variable to set TypeScript location, if it's located outside of project directory.
ERROR: TypeScript dependency was not found and it is required for analysis.
ERROR: Install TypeScript in the project directory or use NODE_PATH env. variable to set TypeScript location, if it's located outside of project directory.
##[error]ERROR: Missing TypeScript dependency
Run Code Online (Sandbox Code Playgroud)
该分析适用于 javascript 文件,但不适用于 typescript 文件。我在 package.json 中将typescript包作为开发依赖项安装,但 SonarCloud 似乎忽略了它。
我找到的文档和主题与 SonarQube 版本相关,但我不知道如何使用SonarCloud进行设置。
默认情况下,node_modules如果您使用的是 Visual Studio,则本地项目文件夹中的文件夹不会添加到源代码管理中。
由于Run Code Analysis任务找不到package.json文件中定义的依赖包,因此会发生此错误。我的可重现步骤:
然后我在安装缺少的软件包npm install之前添加一项任务:Prepare Analysis task
NodeJS 是我的项目名称。同样在 Devops 存储库中,这是 package.json 所在文件夹的名称。
然后这个问题就在我的管道中消失了:
希望它也能帮助您解决问题:)
另外:node_modules如果需要,您还可以选择将本地文件夹添加到源代码管理中。但在 Azure Devops 服务中不建议这样做。
| 归档时间: |
|
| 查看次数: |
5565 次 |
| 最近记录: |