VSTS Extension - Get build URL

Viewed 1460

I'm developing a VSTS extension in Javascript.

In one of my tasks, I need to get a link to my build results. I tried to read from {$Build.BuildUri} but it gives me vstfs:///Build/Build/{buildId} and not a real link.

How can I get a direct link to my build results? I need it both in build and in release pipelines.

1 Answers

The build result page use the URL formatted as below:

https://{vstscollectionuri}/{projectname}/_build/results?buildId={buildid}&_a=summary

And you can get these information via the Predefined Build Variables during the build. In your build task, get the following variables and then combine them to the build result URL.

  • System.TeamFoundationCollectionUri
  • System.TeamProject
  • Build.BuildId
Related