如何在 Azure Devops 中发布对项目成员安全的 HTML 报告?

suc*_*awk 4 azure-devops azure-pipelines azure-devops-wiki

我可以在 Azure DevOps 中的某个位置发布对项目成员安全的html 报告吗?

例如,我想通过 Azure Repos(例如支持 Azure Project Wiki 的存储库)上的预定管道运行repostat或某些类似工具,并将结果发布到可从 Project Wiki 链接的位置。

我有什么选择?

Lev*_*SFT 6

如果您想在azure devops中显示html报告,恐怕目前无法完成。

有用户的声音已经提交给微软。你可以去投票给他们。请参阅此处此线程此线程

但是,您可以使用管道中的发布构建工件任务将 html 报告作为构建工件发布到 azure devops 服务器。

- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: path/to/htmlReportFolder
    artifactName: HtmlReport
Run Code Online (Sandbox Code Playgroud)

然后您可以在构建摘要页面中获取报告。

在此输入图像描述

您可以通过选中构建摘要页面中的保留选项来保留此构建工件。或者为构建设置保留策略。

在此输入图像描述

保护您的 html 报告。您可以从管道运行页面转到安全管理页面来修改此构建的访问权限。

在此输入图像描述

还有一个您可能会觉得有用的发布 HTML 扩展。您可以在您的组织中安装此扩展,并在管道中添加发布 HTML 任务以发布 html 报告。

您可以查看的另一个选项是创建一个 git 存储库来托管 html 报告。您可以添加脚本任务来运行 git 命令。例如 powershell 任务中的脚本。

git config --global user.email "email@example.com"
git config --global user.name "name"

#clone the htmlReportRepo in the agent folder
git clone https://$(system.accesstoken)@dev.azure.com/org/proj/_git/htmlReportRepo

#copy the html report to the htmlReportRepo repo 
Copy-Item path/to/report.html -Destination htmlReportRepo/report.html -Force 

cd htmlReportRepo
# commit the new html report.
git add .
git commit -m 'message'
# push back to htmlReportRepo azure repo.
git push https://$(system.accesstoken)@dev.azure.com/org/proj/_git/htmlReportRepo/ HEAD:master -q
Run Code Online (Sandbox Code Playgroud)