首页 文章

在VSTS持续部署中打开发布失败的错误

提问于
浏览
2

我已在VSTS for Azure解决方案部署中配置并计划了仅具有PowerShell任务的发布定义 . 但是如果发布/部署失败,我想在VSTS中打开一个bug或工作项 .

是否有可能在VSTS .

1 回答

  • 1

    是的,如果发布失败,VSTS可能会创建一个错误 .

    如果上一个任务失败,请在发布定义的末尾添加另一个 PowerShell task 以创建错误 . PowerShell任务的详细设置如下:

    为Rume此任务选项选择 Only when a previous task has failed ,因此如果上一个任务失败,将执行此PowerShell任务 .

    enter image description here

    将powershell脚本添加到create a bug work item,如:

    $witType="Bug"
    $witTitle="title"
    $u="https://account.visualstudio.com/DefaultCollection/project/_apis/wit/workitems/`$$($witType)?api-version=1.0"
    $body="[
      {
        `"op`": `"add`",
        `"path`": `"/fields/System.Title`",
        `"value`": `"$($witTitle)`"
      }
    ]"
    $user = "username"
    $token = "PAT"
    
    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
    $result=Invoke-RestMethod -Method PATCH -Uri $u -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -ContentType "application/json-patch+json" -Body $body
    

相关问题