3

Can I publish an html report somewhere in Azure DevOps that is secured to members of the project?

For example, I want to run repostat, or some similar tool, via a scheduled pipeline on my Azure Repos (e.g. the repo that backs the Azure Project Wiki) and publish the results somewhere that is linkable from the Project Wiki.

What are my options?

artless noise
  • 21,212
  • 6
  • 68
  • 105
successhawk
  • 3,071
  • 3
  • 28
  • 44

1 Answers1

5

If you want to display the html report in azure devops, i am afraid i cannot be done currently.

There are user voices have been submitted to microsoft. You can go vote them up. See here, this thread, and this thread.

Howerver, You can publish the html report to azure devops server as build artifacts by using publish build artifacts task in your pipeline.

- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: path/to/htmlReportFolder
    artifactName: HtmlReport

Then you can get the report in the build summary page.

enter image description here

You can retain this build artifacts by check the retain option in the build summary page. Or set a retention policy for the build.

enter image description here

To secure your html report. You can go the security Manage page from your pipeline runs page to modify the access permission for this build.

enter image description here

There is also an Publish HTML extension you might find useful. You can install this extension in your organization and add Publish HTML task in your pipeline to publish the html report.

Another option you can check out is to create a git repo to host the html report. You can add a script task to run git commands. For example scripts in powershell task.

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
Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • Very useful response, but I don't use DevOps Server. I will check out HTMLPublish, but at first glance it looks immature. If I publish to my azure repo, then how can I link to the html from my wiki in a way that will make it display as html? – successhawk Aug 28 '20 at 14:05
  • I did actually try "hosting" html from my azure repo yesterday, but the approach I found via APIs only returned content-type: text/plain; charset=utf-8; api-version=5.0-preview.1 https://stackoverflow.com/questions/54137998/is-it-possible-to-have-a-link-to-raw-content-of-file-in-azure-devops/59547731#59547731 . Do you know of another way? – successhawk Aug 28 '20 at 14:14
  • When you select the html report in the repo, There is a `Preview` next to `Contents` Tab. There you can see the preview html display. Is it ok to just copy the url link in the address bar to this preview page in your wiki? – Levi Lu-MSFT Aug 31 '20 at 02:59
  • Sorry, that's not at all what I am looking for. Most of the page is Repos related stuff and that would be distracting. I think the PublishHTML extension is a better option, but I haven't fully vetted it yet. – successhawk Aug 31 '20 at 03:33
  • The Publish HTML extension is no longer available in the Marketplace. – Marco Wedemeyer Oct 18 '22 at 17:56