我在VSTS Release管道中使用带有文件路径的Rollback任务来执行powershell脚本。该脚本将读取任务状态并执行回滚操作。 但是在Release管道中执行它时会遇到错误。
2016-06-07T14:40:29.3618995Z ## [debug]为运行获取个人访问令牌
2016-06-07T14:40:42.1723249Z ## [debug]使用获取的PAT令牌调用https://aced.vsrm.visualstudio.com/HON.ACS.PIM.DAM.FWD/_apis/release/releases/158/environments/158/tasks?api-version=2.1-preview.1
2016-06-07T14:40:42.6644892Z ## [debug]无法获取发布任务状态
2016-06-07T14:40:42.6675181Z ## [debug]远程服务器返回错误:(500)内部服务器错误。
2016-06-07T14:40:42.6714886Z ## [debug]发布查询失败。
2016-06-07T14:40:42.6905170Z ## [debug]获取任务执行历史记录为{}
使用的脚本如下:
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..."
}
}
尝试了内联脚本和文件路径方法,但没有奏效。 请帮忙。