I am storing some artifacts from my build pipeline to Artifacts folder using the below statements:
Write-Host "##vso[artifact.upload containerfolder=testresult;artifactname=worksoftresult;]C:\JSONOutput\finalJSON.json"
Now I want to access this particular json file from an Azure DevOps extension that I want to create. Like the following code give me the current logged in user in the extension:
document.getElementById("name").innerText = VSS.getWebContext().user.name;
Is there a way to access the artifacts of the current build from VSS.SDK? If not, how to access the artifacts? I have tried the GetAtrifact rest API, but it tries to download the file:
https://dev.azure.com/XXXX/XXXXX/_apis/build/builds/1166/artifacts?artifactName=testResult&fileName=finalJSON.json&api-version=5.1&%24format=json
I dont want to download the json file but I want the json to show it in the extension. Please help.
To answer my question, since I was not able to show artifacts directly in an extension, I have alternatively (for the time being) uploaded it to Task.UploadSummary using the following piece of code:
Write-Host "##vso[task.uploadsummary]$(Build.ArtifactStagingDirectory)\output.md"
This is not totally serving my purpose but I am able to see an Extensions tab in build summary where the file which should have been in artifact is getting rendered: