问题
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