如何在Azure DevOps的生成摘要中查看SonarQube完整分析报告? [英] How to view the SonarQube full analysis report in the build summary in Azure DevOps?

查看:105
本文介绍了如何在Azure DevOps的生成摘要中查看SonarQube完整分析报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法在Azure DevOps生成摘要中查看SonarQube结果.

Not able to view SonarQube results in the Azure DevOps build summary.

我在build.yml中为.netccore和框架组件添加了代码覆盖率单元测试任务,但是当我尝试运行该构建时,它仅显示单元测试任务的代码覆盖率.分析,包括代码气味,天蓝色devops构建摘要本身中包含多少行以及质量门结果.由于一些挑战,我无法登录SonarQube机器,因此我想在构建摘要中查看结果.我已经在build.yml文件中添加了SonarQube任务以运行分析.

I have added code coverage unit test task in the build.yml for my .netccore and framework component but when I try running the build its showing the code coverage for unit test tasks only.I am not sure how to check the full analysis including code smells and how many lines covered and quality gate result as well in the azure devops build summary itself.Due to some challenges I couldn't able to loginto my SonarQube machine so I wanted to view the results in the build summary itself.I have added the SonarQube task to run analysis in the build.yml file.

Build.yml:

name: $(date:yyyyMMdd)$(rev:.r)-$(SourceBranchName)

variables:
  BuildPlatform: 'Any CPU'
  BuildConfiguration: 'Release'
  Major: '0'
  Minor: '1'
  nugetversion: $(Major).$(Minor).$(Build.BuildId)
steps:
- task: DotNetCoreInstaller@0
  displayName: 'Use .NET Core SDK Tool Installer'
  inputs:
    version: 2.2.100
#Restore nuget for Test123
- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    vstsFeed: 'Test'

- task: SonarSource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@4
  displayName: 'Prepare analysis on SonarQube'
  inputs:
    SonarQube: dksonarqubep01

    projectKey: 'TestKey'

    projectName: 'Test123'

  continueOnError: true

#Build solution for Test123
- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)/deployment'
  inputs:
    SourceFolder: deployment

    Contents: '**\*.*'

    TargetFolder: '$(build.artifactstagingdirectory)/deployment'

    CleanTargetFolder: true
- task: DotNetCoreCLI@2
  displayName: 'Build proj Test123'
  inputs:
    command: build
    projects: 'Test123.sln'
    arguments: '-c $(BuildConfiguration) --no-restore'

- task: DotNetCoreCLI@2
  displayName: 'dotnet test'
  inputs:
    command: test

    projects: |
     Test123.Tests/*.csproj

    arguments: '-c $(BuildConfiguration) --no-restore --no-build --collect:"Code coverage"'   

- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: publish

    publishWebProjects: false

    projects: '**/*Test123.csproj'

    arguments: '-c $(BuildConfiguration) -o $(build.artifactstagingdirectory) --no-restore'


- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**\\bin\\**\\*.pdb'

    PublishSymbols: false

  continueOnError: true

- task: CopyFiles@2
  displayName: 'Copy deployment to: $(build.artifactstagingdirectory)'
  inputs:
    SourceFolder: deployment

    TargetFolder: '$(build.artifactstagingdirectory)\\env'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

    ArtifactName: 'drop'

- task: SonarSource.sonarqube-9589-4B15-8491-8164AEB38055.SonarQubeAnalyze@4
  displayName: 'Run Code Analysis'
  continueOnError: true

- task: SonarSource.sonarqube-1ee4-45d3-b1b0-bf822d9095ef.SonarQubePublish@4
  displayName: 'Publish Quality Gate Result'
  continueOnError: true

在单元测试的构建摘要中我只能看到代码覆盖率百分比值,但是我希望在构建摘要中看到完整的分析,而不是登录SonarQube机器并查看结果.如果有任何任务需要,请帮我无需登录SonarQube机器就可以在build.yml中执行任务以查看结果,或通过其他方式在azure DevOps中查看结果.

I could see only code coverage percentage value in the build summary for unit tests but I would like to see the complete analysis in the build summary rather than login to SonarQube machine and see the results.Kindly help me if there any task need to task in the build.yml to see the results or any other way to see the results in the azure DevOps without login to SonarQube machine.

推荐答案

如何在Azure DevOps的构建摘要中查看SonarQube完整分析报告?

How to view the SonarQube full analysis report in the build summary in Azure DevOps?

AFAIK,在任务 Prepare Analysis Configuration 的版本 3 中,有一个高级选项在构建摘要中包含完整的分析报告.名为 MSBuild扫描程序-开始分析:

AFAIK, there is the advanced option Include full analysis report in build summary in the version 3 of the task Prepare Analysis Configuration, which named Scanner for MSBuild - Begin Analysis:

用于上载报告以生成构建摘要,结果将显示在构建摘要的底部.

It is used to upload the report to build summary and the result will be show in the bottom of build summary.

或者,您可以尝试上传结果文件以通过),它将显示在构建摘要的底部.

Alternatively, you can try upload the result files to build through Logging Command (e.g. Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=testsummaryname;]c:\testsummary.md") and it will show in the bottom of build summary.

上传摘要减价并将其附加到当前时间轴记录.这摘要应添加到构建/发布摘要中,并且不可用与日志一起下载.

Upload and attach summary markdown to current timeline record. This summary shall be added to the build/release summary and not available for download with logs.

希望这会有所帮助.

这篇关于如何在Azure DevOps的生成摘要中查看SonarQube完整分析报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆