【发布时间】:2018-05-06 02:26:00
【问题描述】:
我正在尝试使用 power shell 在 VSTS 中创建一个工作项,我将在我的一些自定义解决方案中使用它
谁能帮我写剧本?
【问题讨论】:
-
你尝试了什么,什么不起作用?请编辑问题,以便我们为您提供帮助
标签: powershell azure-devops azure-devops-rest-api
我正在尝试使用 power shell 在 VSTS 中创建一个工作项,我将在我的一些自定义解决方案中使用它
谁能帮我写剧本?
【问题讨论】:
标签: powershell azure-devops azure-devops-rest-api
参考这个脚本:
param(
[string]$witType,
[string]$witTitle
)
$u="https://[account].visualstudio.com/DefaultCollection/[team project]/_apis/wit/workitems/`$$($witType)?api-version=1.0"
$body="[
{
`"op`": `"add`",
`"path`": `"/fields/System.Title`",
`"value`": `"$($witTitle)`"
}
]"
$user = "test"
$token = "[personal access token]"
$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
参数:-witType "task" -witTitle "PowerShellWIT1"
【讨论】: