【问题标题】:In TFS (or ADO) is there an API call to link a Team to an Area Path?在 TFS(或 ADO)中是否存在将团队链接到区域路径的 API 调用?
【发布时间】:2020-04-08 13:54:45
【问题描述】:

我们正在自动创建 TFS 团队/董事会,发现有一个 API 可以创建团队和一个 API 来创建区域路径,但没有一个可以链接这两者。基本上,我们正在寻找充当“使用团队名称创建区域路径”的内容。附图中的复选框。Screenshot 这是我们团队帖子的代码:

$azdoURI = https://prd-ourCompanyName/tfs/ourOrg/_apis/projects/ourProject/teams?api-version=5.0"
$requestBody = @{ name = "$boardName" }
$jsonRequestBody = $requestBody | ConvertTo-Json -Compress

$response = (Invoke-WebRequest -Method Post -Uri $azdoURI -Body $jsonRequestBody -Content 'application/json' -Credential $credential -UseBasicParsing)

【问题讨论】:

  • 团队是指团队项目吗?你用的是哪个rest api?
  • 是 - 团队作为团队项目中的团队。我们有一个成功的功能,我刚刚添加到上面的帖子中,它添加了团队。从 Microsoft 文档中,下面的 POST 应该添加区域路径。我只是还没有找到一种方法将它们结合在一起。 POST dev.azure.com{organization}/{project}/_apis/wit/classificationnodes/{structureGroup}/{path}?api-version=5.1
  • 旧的 API 示例可以在这里找到:stackoverflow.com/a/12850331/736079
  • 您好 pharmer40,这个问题有更新吗?

标签: tfs azure-devops azure-devops-rest-api azure-boards


【解决方案1】:

通过/_apis/work/teamsettings/iterations API 向团队添加迭代。

请求:

POST https://dev.azure.com/fabrikam/Fabrikam-Fiber/_apis/work/teamsettings/iterations?api-version=5.1
"{\"id\":\"a589a806-bf11-4d4f-a031-c19813331553\"}"

回复:

{
  "id": "a589a806-bf11-4d4f-a031-c19813331553",
  "name": "Sprint 2",
  "path": "Fabrikam-Fiber\\Release 1\\Sprint 2",
  "attributes": {
    "startDate": null,
    "finishDate": null
  }
}

要设置区域路径,请使用/_apis/work/teamsettings/teamfieldvalues:

请求:

PATCH https://dev.azure.com/fabrikam/Fabrikam-Fiber/_apis/work/teamsettings/teamfieldvalues?api-version=5.1
{
  "defaultValue": "Fabrikam-Fiber\\Auto",
  "values": [
    {
      "value": "Fabrikam-Fiber\\Auto",
      "includeChildren": true
    },
    {
      "value": "Fabrikam-Fiber\\Fiber",
      "includeChildren": false
    },
    {
      "value": "Fabrikam-Fiber\\Optics",
      "includeChildren": false
    }
  ]
}

回复:

{
  "field": {
    "referenceName": "System.AreaPath",
    "url": "https://dev.azure.com/fabrikam/_apis/wit/fields/System.AreaPath"
  },
  "defaultValue": "Fabrikam-Fiber\\Auto",
  "values": [
    {
      "value": "Fabrikam-Fiber\\Auto",
      "includeChildren": true
    },
    {
      "value": "Fabrikam-Fiber\\Fiber",
      "includeChildren": false
    },
    {
      "value": "Fabrikam-Fiber\\Optics",
      "includeChildren": false
    }
  ]
}

另见:

【讨论】:

  • 据您所知,有没有办法使用客户端 SDK 来做到这一点? Here's the problem我正在努力解决。
【解决方案2】:

基本上,我们正在寻找可以充当“创建区域”的东西 带有团队名称的路径。' 附件图片中的复选框。

如果我理解你的话,你正在尝试创建一个新的团队项目,其中有一个默认区域路径。 (当然你也希望他们的名字应该一样)

对于 TFS2018U2,尝试:

POST https://{instance}/{collection}/_apis/projects?api-version=4.1

对于 Azure Devops Server 2019,请尝试:

POST https://{instance}/{collection}/_apis/projects?api-version=5.0

您可以在我的另一篇帖子here 中找到更多详细信息。经过我的检查,这个api会自动定义与团队项目同名的默认区域路径:

【讨论】:

  • 抱歉耽搁了 - 我们的故事有段时间退出了。这看起来像我需要的。我很快就会尝试。
  • 据您所知,有没有办法使用客户端 SDK 来做到这一点? Here's the problem我正在努力解决。
【解决方案3】:

所以这就是我结束的地方: 5 个步骤:

  1. 创建团队:POST https://dev-tfs.../{organization}/_apis/projects/{project}/teams?api-version=5.1 正文:{"name":"BoardByPostmanTest_3"}
  2. 创建匹配团队的区域路径:POST https://dev-tfs.../{organization}/{project}/_apis/wit/classificationnodes/Areas?api-version=5.1 正文:{"name":"BoardByPostmanTest_3"}
  3. 使用区域路径更新团队:PATCH https://dev-tfs.z../{organization}/{project}/BoardByPostmanTest_3/_apis/work/teamsettings/teamfieldvalues?api-version=5.1 身体: { "defaultValue": "Agile\BoardByPostmanTest_3", “价值观”:[ { "value": "Agile\BoardByPostmanTest_3", “包括儿童”:真 } ] }
  4. 查找项目迭代:GET https://dev-tfs.../{organization}/{project}/_apis/wit/classificationnodes/Iterations?api-version=5.1
  5. 将该迭代添加到团队:PATCH https://dev-tfs.../{organization}/{project}/BoardByPostmanTest_3/_apis/work/teamsettings?api-version=5.1 身体: { "backlogIteration": "无论迭代号是从步骤 4 中的 GET 得到的" }

感谢 jessehouwing 提供了我错过的第 3 步。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-31
    • 1970-01-01
    • 1970-01-01
    • 2017-01-14
    • 2013-12-20
    • 2020-06-09
    • 1970-01-01
    • 2017-03-29
    相关资源
    最近更新 更多