首页 > 解决方案 > 声纳:检查 node_modules 时 TFS“发布质量门结果”任务失败

问题描述

node_modules是 yarn(或 npm)存储依赖项的位置。

我正在使用 TFS 任务对具有此标准配置的 angular 7 项目执行 SonarQube 分析:

在此处输入图像描述

“发布质量门结果”任务因以下错误而失败:

2019-02-06T16:15:40.1474327Z ##[debug]findPath: 'C:\Agt2\_work\14'
2019-02-06T16:15:40.1474945Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2019-02-06T16:15:40.1475394Z ##[debug]findOptions.followSymbolicLinks: 'true'
2019-02-06T16:15:40.1480701Z ##[debug]  C:\Agt2\_work\14 (directory)
[...]
2019-02-06T16:15:41.2684833Z ##[debug]  C:\Agt2\_work\14\s\node_modules\@angular\cli (directory)
2019-02-06T16:15:41.2692225Z ##[debug]  C:\Agt2\_work\14\s\node_modules\@angular\cli\.bin (directory)
2019-02-06T16:15:41.2779828Z ##[debug][SQ] Publish task error: Failed find: ENOENT: no such file or directory, stat 'C:\Agt2\_work\14\s\node_modules\@angular\cli\.bin\ng'
2019-02-06T16:15:41.2781059Z ##[debug]task result: Failed
2019-02-06T16:15:41.2782877Z ##[error]Failed find: ENOENT: no such file or directory, stat 'C:\Agt2\_work\14\s\node_modules\@angular\cli\.bin\ng'

第一个问题:为什么声纳分析 node_modules 而我将它添加到“准备分析”任务中的排除文件中:

sonar.exclusions=**/node_modules/**,**/*.spec.ts

第二个问题:如果我将这些选项添加到“准备分析”任务中的附加属性中,似乎忽略了该选项:

findOptions.followSpecifiedSymbolicLink='false'
findOptions.followSymbolicLinks:'false'

结果 : 在此处输入图像描述

以及如何解决此问题以获取单元测试结果并将其发布到 sonarqube ?

编辑:在 Sonar JIRA 上创建的票证: https ://community.sonarsource.com/t/vsts-publish-quality-gate-result-with-npm-parses-node-modules-folder-and-hangs-on-symbolic-链接/7058

编辑 2:声纳团队回答我说它与这个错误相似: https ://jira.sonarsource.com/browse/VSTS-172

标签: angulartfssonarqube

解决方案


Finnaly 找到了如何通过在构建工作流程中添加新的 powershell 脚本来修复它。

在这个 powershell 脚本中,我执行rimraf node_modues删除所有 node_modules 文件的脚本。

这不是解决方法,而是目前唯一有效的解决方法。

在此处输入图像描述


推荐阅读