我正在使用帶有文件路徑的回滾任務將其發送到VSTS發佈管道中的powershell腳本。該腳本將讀取任務狀態並執行回滾操作。 但在釋放管道中執行它時出現錯誤。無法獲取VSTS回滾任務中的發佈任務狀態
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 {}
使用的腳本下面給出:
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..."
}
}
嘗試都內嵌腳本和文件路徑的方法,但沒有奏效。 請幫忙。
當您使用Fiddler跟蹤呼叫時,您會看到什麼:https://aced.vsrm.visualstudio.com/HON.ACS.PIM.DAM.FWD/_apis/release/releases/158/environments/ 158/tasks?api-version = 2.1-preview.1',它返回一個內部服務器錯誤的事實清楚地表明你的腳本沒有出錯,該任務正在拋出一個錯誤。 – jessehouwing