SonarQube分析特定文件

唐·德雷珀

我正在尝试使用sonarqube分析我想每天运行的azure devops git存储库中的特定文件(filename.ts)。

到目前为止,我已经建立了:

  1. A sonarqube project and generated project token in our sonarqube saas.
    
  2. Created a CD release pipeline in Azure DevOps including the predefined sonarqube tasks:
    
        *    prepare analysis on sonarqube (unclear to me how I configure this)
        *    run code analysis (looks as if this doesn't require configuration)
        *    publish quality gate (same belief here that it doesn't require configuration)
    
  3. Identified the repository where the file exists in the azure repo. 
    
  4. I have also discovered the artifact name that the repo's CI pipeline generates.
    
  5. Found a preconfigured sonarqube service connection in Azure DevOps.
    

我现在挠头的地方是确定以下几点:

a.  How to tell my CD pipeline where the file is in the azure repo. Should I point it to the file in the Repo? Or should i take it from the CI artifact?

b.  Would the sonarqube project require further configuration so to see the file?

我觉得这个谜题还有更多内容。有人可以指出正确的道路吗,请包括我可能未曾想到的其他内容?

李维·鲁

首先,您需要检查预配置的声纳服务连接是否指向您的声纳主机。

转到Project settingsazure devops-> Service connections->选择预先配置的sonarqube service connection->单击Edit->检查Server Url指向您的声纳主机网址的位置。

如果预配置的声纳服务连接指向其他声纳主机。您需要为您的声纳主机创建一个新的声纳服务连接。

分析特定文件

您可以将sonar.inclusions属性设置为仅分析特定文件。参见下图。请查看文档缩小焦点以获取更多信息。

在此处输入图片说明

您可以在发布管道的“准备分析配置”任务sonar.inclusionsAdditional Properties字段中配置属性

在此处输入图片说明

或者,您也可以sonar.inclusions在SonarQube项目UI中设置属性。

要使用排除项仅分析sonar.sources中文件的指定子集,请转至“项目设置”>“常规设置”>“分析范围”>“文件”。

  • 源文件包含
  • 测试文件包含

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章