Open a bug on release fails in VSTS Continuous Deployment

纵然是瞬间 提交于 2021-01-28 01:50:32

问题


I have configured and scheduled only release definition on VSTS for Azure solution deployment which is having PowerShell tasks. But I want to open a bug or work item in VSTS if release/ deployment fails.

Is it possible in VSTS.


回答1:


Yes, it’s possible for VSTS to create a bug if a release failed.

Add another PowerShell task in the end of your release definition to create a bug if the previous task fails. Detail settings for the PowerShell task as below:

Select Only when a previous task has failed for Rume this task option, so if the previous task failed, this PowerShell task will be executed.

The add the powershell script to create a bug work item like:

$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


来源:https://stackoverflow.com/questions/48184504/open-a-bug-on-release-fails-in-vsts-continuous-deployment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!