2016-06-07 36 views
1

我正在使用带有文件路径的回滚任务将其发送到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..." 
    } 
} 

尝试都内嵌脚本和文件路径的方法,但没有奏效。 请帮忙。

+0

当您使用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

回答

0

API中所需的API版本有变化,它为您提供任务状态。将您的任务脚本更新到最新版本的API。 请参考VSTS论坛here的提问和回答。