【问题标题】:Could not obtain release tasks status in VSTS Rollback task在 VSTS 回滚任务中无法获取发布任务状态
【发布时间】:2016-06-07 15:18:41
【问题描述】:

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

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) Internal Server Error.

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..."
    }
}

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

【问题讨论】:

  • 当你使用 Fiddler 跟踪调用到:https://aced.vsrm.visualstudio.com/HON.ACS.PIM.DAM.FWD/_apis/release/releases/158/environments/158/tasks?api-version=2.1-preview.1 时你看到了什么,它返回一个内部服务器错误的事实清楚地表明你的脚本没有错误,任务正在抛出一个错误。

标签: powershell azure-devops powershell-3.0 azure-pipelines-release-pipeline


【解决方案1】:

API 中需要更改 API 版本,为您提供任务状态。将您的任务脚本更新为最新版本的 API。 请参考VSTS论坛here问答。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-14
    • 1970-01-01
    相关资源
    最近更新 更多