通过 PowerShell 在 TFS 中创建任务
Create task in TFS via PowerShell
我需要使用 PowerShell 在 TFS 中创建一个任务
我使用了 VSTeam(TFS/Azure DevOps 中许多功能的 PowerShell 模块)。项目已创建。我有一个描述模板,但我不知道如何将它插入到获取字符串的描述中
这是模板的示例:
该构建是一个 hyper link 也是 tfs 项目(补丁 XXXX)
我怎样才能建立这样的字符串?如何为项目创建 link?
如何设置粗体字符串?
我可以从 TFS 复制 link 吗?
有一个新版本。构建位置:
\XXXXX\global\QA\
添加的补丁:
Patch 1269263: "Title"
Patch 1271540: "Title"
你调查过 VSTeam 了吗?用于 TFS / Azure DevOps 中许多功能的 PowerShell 模块。
Set-VSTeamAccount -Account http://localtfs:8080/tfs/DefaultCollection -UseWindowsAuthentication
Set-VSTeamDefaultProject Demo
$additionalFields = @{"System.Tags"= "TestTag"; "System.AreaPath" = "Project\MyPath"}
Add-VSTeamWorkItem -Title "New Work Item" -WorkItemType Task -AdditionalFields $additionalFields
ID Title Status
-- ----- ------
6 New Work Item To Do
TFS/Azure DevOps 中的描述字段包含 HTML 文本。任何格式都可以使用标准 HTML 结构来完成。 <i>
表示斜体,<b>
表示粗体 <a href="https://.....">
表示 links.
要获取 links,您可能需要调用其他 REST APIs 来获取构建详细信息。大多数 APE 结果都有一个 links 集合和一个网络 link,你可以用它来将人们引导到那个东西的网页。
来自 Build/GET API 调用的示例:
GET https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/builds/2817
{
"_links": {
"self": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/Builds/2817"
},
"web": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_build/results?buildId=2817"
},
"sourceVersionDisplayUri": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/builds/2817/sources"
},
"timeline": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/builds/2817/Timeline"
},
"badge": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/status/36"
}
},
...
...
}
在这种情况下,self
是检索到该文档的 link。 web
等同于网络UI等
您会发现 API 返回的其他元素带有 url
属性。按照 URL,您还将获得该对象的 _links
集合:
...
...
"project": {
"id": "a88536a2-a889-45a3-a955-ddf1af8aeba1",
"name": "azure-devops-extensions",
"description": "This projects hosts the pipelines for all my Azure DevOps marketplace extensions.",
"url": "https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1",
"state": "wellFormed",
"revision": 414360082,
"visibility": "public",
"lastUpdateTime": "2019-06-28T09:48:16.943Z"
},
以下:
GET https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1
{
"id": "a88536a2-a889-45a3-a955-ddf1af8aeba1",
"name": "azure-devops-extensions",
"description": "This projects hosts the pipelines for all my Azure DevOps marketplace extensions.",
"url": "https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1",
"state": "wellFormed",
"revision": 414360082,
"_links": {
"self": {
"href": "https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1"
},
"collection": {
"href": "https://dev.azure.com/jessehouwing/_apis/projectCollections/6ac92044-9ce2-40d0-b882-f6b6648dff8b"
},
"web": {
"href": "https://dev.azure.com/jessehouwing/azure-devops-extensions"
}
},
"visibility": "public",
"defaultTeam": {
"id": "7edc4d0a-3d22-44ee-a6cd-96a3dbf0690f",
"name": "azure-devops-extensions Team",
"url": "https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1/teams/7edc4d0a-3d22-44ee-a6cd-96a3dbf0690f"
},
"lastUpdateTime": "2019-06-28T09:48:16.943Z"
}
这样您可以将 link 收集到适当的 UI 页面以将您的用户引导至。
我需要使用 PowerShell 在 TFS 中创建一个任务
我使用了 VSTeam(TFS/Azure DevOps 中许多功能的 PowerShell 模块)。项目已创建。我有一个描述模板,但我不知道如何将它插入到获取字符串的描述中 这是模板的示例: 该构建是一个 hyper link 也是 tfs 项目(补丁 XXXX) 我怎样才能建立这样的字符串?如何为项目创建 link? 如何设置粗体字符串? 我可以从 TFS 复制 link 吗?
有一个新版本。构建位置:
\XXXXX\global\QA\
添加的补丁:
Patch 1269263: "Title"
Patch 1271540: "Title"
你调查过 VSTeam 了吗?用于 TFS / Azure DevOps 中许多功能的 PowerShell 模块。
Set-VSTeamAccount -Account http://localtfs:8080/tfs/DefaultCollection -UseWindowsAuthentication
Set-VSTeamDefaultProject Demo
$additionalFields = @{"System.Tags"= "TestTag"; "System.AreaPath" = "Project\MyPath"}
Add-VSTeamWorkItem -Title "New Work Item" -WorkItemType Task -AdditionalFields $additionalFields
ID Title Status
-- ----- ------
6 New Work Item To Do
TFS/Azure DevOps 中的描述字段包含 HTML 文本。任何格式都可以使用标准 HTML 结构来完成。 <i>
表示斜体,<b>
表示粗体 <a href="https://.....">
表示 links.
要获取 links,您可能需要调用其他 REST APIs 来获取构建详细信息。大多数 APE 结果都有一个 links 集合和一个网络 link,你可以用它来将人们引导到那个东西的网页。
来自 Build/GET API 调用的示例:
GET https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/builds/2817
{
"_links": {
"self": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/Builds/2817"
},
"web": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_build/results?buildId=2817"
},
"sourceVersionDisplayUri": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/builds/2817/sources"
},
"timeline": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/builds/2817/Timeline"
},
"badge": {
"href": "https://dev.azure.com/jessehouwing/a88536a2-a889-45a3-a955-ddf1af8aeba1/_apis/build/status/36"
}
},
...
...
}
在这种情况下,self
是检索到该文档的 link。 web
等同于网络UI等
您会发现 API 返回的其他元素带有 url
属性。按照 URL,您还将获得该对象的 _links
集合:
...
...
"project": {
"id": "a88536a2-a889-45a3-a955-ddf1af8aeba1",
"name": "azure-devops-extensions",
"description": "This projects hosts the pipelines for all my Azure DevOps marketplace extensions.",
"url": "https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1",
"state": "wellFormed",
"revision": 414360082,
"visibility": "public",
"lastUpdateTime": "2019-06-28T09:48:16.943Z"
},
以下:
GET https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1
{
"id": "a88536a2-a889-45a3-a955-ddf1af8aeba1",
"name": "azure-devops-extensions",
"description": "This projects hosts the pipelines for all my Azure DevOps marketplace extensions.",
"url": "https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1",
"state": "wellFormed",
"revision": 414360082,
"_links": {
"self": {
"href": "https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1"
},
"collection": {
"href": "https://dev.azure.com/jessehouwing/_apis/projectCollections/6ac92044-9ce2-40d0-b882-f6b6648dff8b"
},
"web": {
"href": "https://dev.azure.com/jessehouwing/azure-devops-extensions"
}
},
"visibility": "public",
"defaultTeam": {
"id": "7edc4d0a-3d22-44ee-a6cd-96a3dbf0690f",
"name": "azure-devops-extensions Team",
"url": "https://dev.azure.com/jessehouwing/_apis/projects/a88536a2-a889-45a3-a955-ddf1af8aeba1/teams/7edc4d0a-3d22-44ee-a6cd-96a3dbf0690f"
},
"lastUpdateTime": "2019-06-28T09:48:16.943Z"
}
这样您可以将 link 收集到适当的 UI 页面以将您的用户引导至。