openalm / Extension-UtilitiesPack

Release Management utility tasks
Other
34 stars 38 forks source link

Could not obtain release tasks status in VSTS Rollback task #44

Closed gkravi closed 7 years ago

gkravi commented 8 years ago

I am using Rollback task with File Path to powershell script in VSTS Release pipeline. The script will read the task status and execute the rollback action. But while executing it in Release pipeline getting below error.

`2016-06-07T14:40:29.3618995Z ##[debug]Getting Personal Access Token for the Run

2016-06-07T14:40:42.1723249Z ##[debug]Calling https://aced.vsrm.visualstudio.com/HON.ACS.PIM.DAM.FWD/_apis/release/releases/158/environments/158/tasks?api-version=2.1-preview.1 using obtained PAT token

2016-06-07T14:40:42.6644892Z ##[debug]Could not obtain release tasks status

2016-06-07T14:40:42.6675181Z ##[debug]The remote server returned an error: (500) Internal Server Error.

2016-06-07T14:40:42.6714886Z ##[debug]Release Query unsuccessful.

2016-06-07T14:40:42.6905170Z ##[debug]obtained task execution history as {}`

The script used is given below:

try
{
    $jsonobject = ConvertFrom-Json $env:Release_Tasks
}
catch
{
    Write-Verbose -Verbose "Error converting from json"
    Write-Verbose -Verbose $Error
}

foreach ($task in $jsonobject | Get-Member -MemberType NoteProperty) {    
    $taskproperty = $jsonobject.$($task.Name) | ConvertFrom-Json
    Write-Verbose -Verbose "Task $($taskproperty.Name) with rank $($task.Name) has status $($taskproperty.Status)"
    Write-Verbose -Verbose "$($taskproperty.Name)"
    if($taskproperty.Name -eq "Execute Web deploy command" -and $taskproperty.Status -eq  "failure")
    {
        $statuscode = "$($taskproperty.Status)"
        Write-Host $statuscode
        #Setting up the environment variable for package install status
        Write-Output "Web Deploy Status Code is: $statuscode"
        Write-Host ("##vso[task.setvariable variable=statusWebDeploy;]$statuscode")
        Write-Verbose -Verbose "statusWebDeploy:" $env:statusWebDeploy "Initiating Restore Website Folder..."
    }
}

Tried both inline script and File Path approach but did not work. Please help.