Project code is not being analyzed for sonarqube

空扰寡人 提交于 2020-12-16 04:48:48

问题


I have a repo in azure DevOps with only folder as test. Now, I have given the task structure in this way in azure DevOps. But I cannot see the code getting analyzed in sonarqube. The code tab shows blank. Could someone help me with where I am going wrong?? I do not want to give folder name in sources..I want whatever code I add in the branch to be analyzed.

edit: Just realized this is happening only for feature short lived branch..My sonarqube version is 8.0

steps:

  • task: SonarQubePrepare@4 inputs: SonarQube: 'connection name' scannerMode: 'CLI' configMode: 'manual' cliProjectKey: 'pipeline-sonar-demo' cliProjectName: 'pipeline-sonar-demo' cliSources: "." extraProperties: | # Additional properties that will be passed to the scanner, # Put one key=value per line, example: sonar.exclusions=**/*.xml

回答1:


SonarQube extension provides three tasks you will use in your build definitions to analyze your projects:

  • Prepare Analysis Configuration task, to configure all the required settings before executing the build.

    • This task is mandatory.
    • In case of .NET solutions or Java projects, it helps to integrate seamlessly with MSBuild, Maven and Gradle tasks.
  • Run Code Analysis task, to actually execute the analysis of the source code.

    • This task is not required for Maven or Gradle projects, because
      scanner will be run as part of the Maven/Gradle build.
  • Publish Quality Gate Result task, to display the Quality Gate status in the build summary and give you a sense of whether the application is ready for production "quality-wise".

    • This task is optional.
    • It can significantly increase the overall build time because it will poll SonarQube until the analysis is complete. Omitting this task will not affect the analysis results on SonarQube - it simply means the Azure DevOps Build Summary page will not show the status of the analysis or a link to the project dashboard on SonarQube.

It seems you still need add Run Code Analysis task. Regarding how to use SonarScanner for Azure DevOps, please refer to the following documentation:

https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-azure-devops/



来源:https://stackoverflow.com/questions/65032549/project-code-is-not-being-analyzed-for-sonarqube

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!