在您的帐户中安装发布管理实用程序任务扩展后,您将在任务目录中看到一个名为“<strong>Rollback powershell”的任务。对于回滚,您只需将此任务添加到发布定义中并将其标记为“始终运行”。
访问任务执行信息的示例如下。
try
{
$jsonobject = ConvertFrom-Json $env:Release_Tasks
}
catch
{
Write-Verbose -Verbose “Error parsing Release_Tasks environment variable”
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)”
// Perform rollback action required in case $task.Name has status failed
}
请注意,您可能需要更新 api 版本。检查以下情况:
https://social.msdn.microsoft.com/Forums/expression/en-US/aacab4c3-b25b-4348-90b1-4d5661d9d148/release-management-utility-tasks-rollback-task-is-not-working-in- tfs-2017-update-1?forum=tfsbuild