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

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

问题描述

是否有可能利用TFS或TS REST api通过利用工作项commit"ArtifiactLink" url获取有关GIT commit的详细信息?

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/Commit开头的部分. URL格式为

2. Get commit(s) and related repo(s) linked in the above work item

Search in the response of the step1 REST API, get the part which rel is ArtifactLink and the url start with vstfs:///Git/Commit. The URL format is

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,回购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天全站免登陆