从 TFS 工作项工件链接获取 TFS GIT 提交详细信息 [英] Obtain TFS GIT Commit Details From TFS Work Item Artifact Link

查看:20
本文介绍了从 TFS 工作项工件链接获取 TFS GIT 提交详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以利用 TFS 或 TS REST api 通过利用工作项提交ArtifiactLink"url 来获取 GIT 提交的详细信息?

Is it possible to leverage TFS or TS REST api to obtain details for a GIT commit by leveraging the work item commit "ArtifiactLink" url?

推荐答案

因此您希望根据工作项工件链接(而工件链接类型包含提交)获取详细提交信息.

So you want to get detail commit information based on a work item artifacts link (while the artifact link type contains commit).

您可以使用两个 REST API 来实现,详细步骤如下:

You can achieve that with two REST API, detail steps as below:

GET https://{instance}/DefaultCollection/_apis/wit/workitems/{id}?api-version1.0&$expand=all

对于 TFS2015,格式如下:

For TFS2015, the format looks like:

GET http://tfsServer:8080/tfs/DefaultCollection/_apis/wit/workitems?ids={id}&$expand=all&api-version=1.0

对于 VSTS,格式如下:

For VSTS, the format looks like:

GET https://account.visualstudio.com/DefaultCollection/_apis/wit/workitems?ids=7&$expand=all&api-version=1.0

2.获取上述工作项中链接的提交和相关存储库

在step1 REST API的响应中搜索,得到relArtifactLinkurlvstfs开头的部分:///Git/提交.网址格式为

vstfs:///Git/Commit/{project ID}%2F{repo ID}%2F{commit ID}

例如 REST API 响应的一部分:

Such as part of the REST API response as:

{
   "rel": "ArtifactLink",
   "url": "vstfs:///Git/Commit/b959f22b-eeb7-40dc-b37e-986377eaa86f%2F4cfde261-fec3-451c-9d41-a400ba816110%2Fb3c3c5b8718f403402be770cb3b5912df7c64dd6",
   "attributes": {
      "authorizedDate": "2017-09-26T03:14:03.98Z",
      "id": 92,
      "resourceCreatedDate": "2017-09-26T03:14:03.98Z",
      "resourceModifiedDate": "2017-09-26T03:14:03.98Z",
      "revisedDate": "9999-01-01T00:00:00Z",
      "name": "Fixed in Commit"
    }
}

项目ID为b959f22b-eeb7-40dc-b37e-986377eaa86f,repo ID为2F4cfde261-fec3-451c-9d41-a400ba816110,提交ID为代码>b3c3c5b8718f403402be770cb3b5912df7c64dd6.

The project ID is b959f22b-eeb7-40dc-b37e-986377eaa86f, the repo ID is 2F4cfde261-fec3-451c-9d41-a400ba816110 and the commit ID is b3c3c5b8718f403402be770cb3b5912df7c64dd6.

使用您在第 2 步中获得的项目 ID、存储库 ID 和提交 ID 到 获取单个提交:

Use the project ID, repo ID and commit ID you get in step2 to get a single commit:

GET https://{instance}/DefaultCollection/{project ID}/_apis/git/repositories/{repo ID}/commits/{commit ID}?api-version={version}

对于 TFS 2015,格式如下:

For TFS 2015, the format looks like:

GET http://tfsServer:8080/tfs/DefaultCollection/{project ID}/_apis/git/repositories/{repo ID}/commits/{commit ID}?api-version=1.0

对于 VSTS,格式如下:

For VSTS, the format looks like:

GET https://account.visualstudio.com/DefaultCollection/{project ID}/_apis/git/repositories/{repo ID}/commits/{commit ID}?api-version=1.0

这篇关于从 TFS 工作项工件链接获取 TFS GIT 提交详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆