首页 文章

无法在VSTS回滚任务中获取发布任务状态

提问于
浏览
1

我在VSTS Release管道中使用带有文件路径的回滚任务来执行powershell脚本 . 该脚本将读取任务状态并执行回滚操作 . 但是在Release管道中执行它时会遇到错误 .

2016-06-07T14:40:29.3618995Z ## [debug]为运行获取个人访问令牌2016-06-07T14:40:42.1723249Z ## [debug]调用https://aced.vsrm.visualstudio.com /HON.ACS.PIM.DAM.FWD/_apis/release/releases/158/environments/158/tasks?api-version=2.1-preview.1使用获得的PAT令牌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..."
    }
}

尝试了内联脚本和文件路径方法,但没有奏效 . 请帮忙 .

1 回答

  • 0

    API中所需的API版本发生了变化,为您提供了任务状态 . 将任务脚本更新为最新版本的API . 请参阅VSTS论坛here上的问答 .

相关问题