2

Does anyone know here how to update an Artifact's properties? We've had a project assigned to us to move all of our artifact drops from one location to another - This is because our file server is about to die (We use On-Prem Azure DevOps Services)

I've wrote a PowerShell script already that updates what's needed for builds/releases and that works great.

So I wrote another PowerShell script to update what's needed within the Artifacts properties and then uses an "PUT" call to replace the info but there's an issue....

Invoke-RestMethod : {"count":1,"value":{"Message":"The requested resource does not support http method 'PUT'."}}

Does anyone know if this is possible/knows how to do it?

Here's my script;

Example of an endpoint;

https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?api-version=5.1

$artefacts = Get-Content ".\artefacts.txt"
$oldDataURL = "\\rdtstore01.main.rdt.co.uk\Horizon\Drops"
$newDataURL = "\\main.rdt.co.uk\shares\Horizon\Drops"

foreach ($line in $artefacts)
{

    $var = Invoke-RestMethod -Uri $line -UseDefaultCredentials -Method Get

    ### Updte Data line ###
    $data = $var.value.resource.data
    $dataNew = $data -replace [RegEx]::Escape($oldDataURL), $newDataURL
    $var.value.resource.data = @{}
    $var.value.resource.data += @{"value" = $dataNew}
    $result = Invoke-RestMethod -Uri $line -Method Put -ContentType "application/json" -UseDefaultCredentials -Body (ConvertTo-Json $var -Depth 10)
}
Matt Taylor
  • 189
  • 1
  • 2
  • 10

1 Answers1

0

Use Rest API to update Artifacts properties is not support right now. We only provide below methods for working with artifacts produced by builds.

enter image description here

Sorry, there is not any workaround, you may have to use build task to publish artifacts again.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Thanks for the reply, I have an open ticket with MS. Apparently there maybe something we can do using the database. But lets wait and see what happens. – Matt Taylor Jul 02 '20 at 14:41