Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
We (Garima Srivastava) have recently added a feature in the product with which you can undelete a release definitions yourself using our rest APIs. This undelete can be done within 4 weeks of deletion and after which the definition is deleted permanently. Here is a sample power-shell script which uses our rest APIs to find the deleted definitions and then undeletes one of them.
param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string] $token ) ## Construct a basic auth head using PAT function BasicAuthHeader() { param([string]$authtoken) $ba = (":{0}" -f $authtoken) $ba = [System.Text.Encoding]::UTF8.GetBytes($ba) $ba = [System.Convert]::ToBase64String($ba) $h = @{Authorization=("Basic{0}" -f $ba);ContentType="application/json"} return $h } # Fill in your account name/project name/definition name $accountName = "aseemb" $projectName = "dockerConf" $definitionNameToRecover = "New Release Definition" # Find the Id of release definition that got deleted $deletedReleaseDefinitionsUri = "https://$accountName.vsrm.visualstudio.com/$projectName/_apis/Release/definitions?api-version=4.0-preview.3&isDeleted=true&searchText=$definitionNameToRecover" $h = BasicAuthHeader $token $deletedDefinitions = Invoke-RestMethod -Uri $deletedReleaseDefinitionsUri -Headers $h -ContentType “application/json" -Method Get $deletedDefinitionJSON = $deletedDefinitions | ConvertTo-Json -Depth 100 write-host "Found the deleted definitions : $deletedDefinitions" $deletedReleaseDefinitionId = $deletedDefinitions.Value[0].id write-host "Found the deleted id : $deletedReleaseDefinitionId " # Recover the deleted release definition $undeleteReason = '{ "Comment" : "Deleted by mistake" }' $undeleteReleaseDefinitionUri = "https://$accountName.vsrm.visualstudio.com/$projectName/_apis/Release/definitions/$deletedReleaseDefinitionId`?api-version=4.0-preview.3" $undeletedDefinition = Invoke-RestMethod -Uri $undeleteReleaseDefinitionUri -Headers $h -ContentType “application/json" -Method Patch -Body $undeleteReason $name = $undeletedDefinition.name write-host "$name recovered successfully"
Please try it out and do let us know in case it does not work for you !!
Note: - This functionality will not be exposed in the UI at-least for next 6 months or so as we are rewriting the RM landing pages UI.
Please sign in to use this experience.
Sign in