Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tfs 如何检索在构建之间签入的变更集(或工作项)列表?_Tfs_Msbuild_Workitem - Fatal编程技术网

Tfs 如何检索在构建之间签入的变更集(或工作项)列表?

Tfs 如何检索在构建之间签入的变更集(或工作项)列表?,tfs,msbuild,workitem,Tfs,Msbuild,Workitem,我需要一个在构建之间进行的变更集(或工作项)列表(如果需要,我可以标记构建)。 我需要为我们的测试团队提供该列表(并发布“变更列表”) MSBuild任务是否能够检索该列表并另存为文件(然后我可以进一步处理该列表)。 或者我需要从C代码连接到TFS并自己检索该列表(我熟悉在C代码中检索工作项)。我们在TFS构建过程中也做了类似的事情。为此,我们在C代码中创建了一个MSBuild自定义任务,用于调用TFS来获取项目。创建自定义任务非常简单 下面是一篇文章,帮助您开始编写MSBuild任务 我假设您

我需要一个在构建之间进行的变更集(或工作项)列表(如果需要,我可以标记构建)。 我需要为我们的测试团队提供该列表(并发布“变更列表”)

MSBuild任务是否能够检索该列表并另存为文件(然后我可以进一步处理该列表)。

或者我需要从C代码连接到TFS并自己检索该列表(我熟悉在C代码中检索工作项)。

我们在TFS构建过程中也做了类似的事情。为此,我们在C代码中创建了一个MSBuild自定义任务,用于调用TFS来获取项目。创建自定义任务非常简单

下面是一篇文章,帮助您开始编写MSBuild任务


我假设您已经知道如何根据您的问题调用TFS。

TFS将自动生成两个成功生成之间签入的所有更改集和相关工作项的列表。您将在生成报告的末尾找到这些列表

您可以设置一个用于与测试人员通信的构建。当该构建成功构建时,测试人员可以查看构建报告,查看自上次构建以来提交了哪些工作项和更改集


如果为生成的生成质量属性设置事件侦听器,则当生成质量字段更改为特定版本时,您可以向测试人员发送电子邮件警报。

这篇博客文章可能就是您要查找的内容。您基本上浏览了所有链接,查找Uri包含“变更集”的内容。似乎没有此属性的特定属性

(从博客中复制以防腐烂)

使用系统;
使用System.Collections.Generic;
使用Microsoft.TeamFoundation.Client;
使用Microsoft.TeamFoundation.WorkItemTracking.Client;
使用Microsoft.TeamFoundation;
使用Microsoft.TeamFoundation.VersionControl.Client;
类ChangesetsFromWorkItems
{
静态void Main(字符串[]参数)
{
如果(参数长度<2)
{
Console.Error.Write(“用法:ChangesetsFromWorkItems[workitemid…]”);
环境。出口(1);
}
TeamFoundationServer服务器=TeamFoundationServerFactory.GetServer(args[0]);
WorkItemStore wiStore=(WorkItemStore)server.GetService(typeof(WorkItemStore));
VersionControlServer vcs=(VersionControlServer)server.GetService(typeof(VersionControlServer));
intworkitemid;
for(int i=1;i
我知道这个线程已经有几年的历史了,但我在尝试完成同样的任务时发现了它。 我已经为此工作了几天,并提出了一个解决方案来完成这项具体任务。(TFS 2010)

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用Microsoft.TeamFoundation.Client;
使用Microsoft.TeamFoundation.VersionControl.Client;
使用Microsoft.TeamFoundation.Build.Client;
命名空间BranchMergeHistoryTest
{
班级计划
{
私有静态Uri tfsUri=新Uri(“http://sctf:8080/tfs");
私有静态TfsTeamProjectCollection tfs=TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri);
静态void Main(字符串[]参数)
{
IBuildServer buildServer=tfs.GetService();
IBuildDefinition buildDef=buildServer.GetBuildDefinition(“项目”、“特定构建”);
IOrderedEnumerable builds=buildServer.QueryBuilds(buildDef).OrderByDescending(build=>build.LastChangedOn);
/*我必须使用一些逻辑来查找最后两个附加了实际变更集的构建-我们有一些没有附加变更集的构建。您可能也需要这样做。*/
IBuildDetail newestBuild=builds.ElementAt(0);
IBuildDetail priorBuild=builds.ElementAt(1);
字符串newestBuildChangesetId=newestBuild.Information.getNodeByType(“AssociatedChangeset”)[0]。字段[“ChangesetId”];
字符串priorBuildChangesetId=priorBuild.Information.GetNodesByType(“AssociatedChangeset”)[0]。字段[“ChangesetId”];
VersionControlServer vcs=tfs.GetService();
常量字符串sourceBranch=@“$sourceBranch ProbablyHEAD”;
常量字符串targetBranch=@“$targetBranch ProbablyRelease”;
VersionSpec versionFrom=VersionSpec.ParseSingleSpec(newestBuildChangesetId,null);
VersionSpec version=VersionSpec.ParseSingleSpec(priorBuildChangesetId,null);
ChangesetMergeDetails结果=vcs.QueryMergesWithDetails(sourceBranch,VersionSpec.Latest,0,targetBranch,VersionSpec.Latest,0,versionFrom,VersionOn,RecursionType.Full);
foreach(结果中的变更集变更。变更集)
{
变更集详细信息=vcs.GetChangeset(change.ChangesetId);
//提取信息ab
using System;
using System.Collections.Generic;

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation;
using Microsoft.TeamFoundation.VersionControl.Client;

class ChangesetsFromWorkItems
{
    static void Main(string[] args)
    {
        if (args.Length < 2)
        {
            Console.Error.Write("Usage: ChangesetsFromWorkItems <server> <workitemid> [workitemid...]");
            Environment.Exit(1);
        }

        TeamFoundationServer server = TeamFoundationServerFactory.GetServer(args[0]);
        WorkItemStore wiStore = (WorkItemStore)server.GetService(typeof(WorkItemStore));
        VersionControlServer vcs = (VersionControlServer) server.GetService(typeof(VersionControlServer));

        int workItemId;
        for (int i = 1; i < args.Length; i++)
        {
            if (!int.TryParse(args[i], out workItemId))
            {
                Console.Error.WriteLine("ignoring unparseable argument {0}", args[i]);
                continue;
            }

            WorkItem workItem = wiStore.GetWorkItem(workItemId);
            List<Changeset> associatedChangesets = new List<Changeset>();
            foreach (Link link in workItem.Links)
            {
                ExternalLink extLink = link as ExternalLink;
                if (extLink != null)
                {
                    ArtifactId artifact = LinkingUtilities.DecodeUri(extLink.LinkedArtifactUri);
                    if (String.Equals(artifact.ArtifactType, "Changeset", StringComparison.Ordinal))
                    {
                        // Convert the artifact URI to Changeset object.
                        associatedChangesets.Add(vcs.ArtifactProvider.GetChangeset(new Uri(extLink.LinkedArtifactUri);
                    }
                }
            }

            // Do something with the changesets.  Changes property is an array, each Change
            // has an Item object, each Item object has a path, download method, etc.
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace Sample
{
    class BuildSample
    {
        public void LoadBuildAssociatedDetails(Uri tpcUri, Uri buildUri)
        {
            TfsTeamProjectCollection collection = new TfsTeamProjectCollection(tpcUri);
            IBuildServer buildServer = collection.GetService<IBuildServer>();
            IBuildDetail buildDetail = buildServer.GetAllBuildDetails(buildUri);

            List<IChangesetSummary> changeSets = InformationNodeConverters.GetAssociatedChangesets(buildDetail);
            VersionControlServer vcs = collection.GetService<VersionControlServer>();
            IEnumerable<Changeset> actualChangeSets = changeSets.Select(x => vcs.GetChangeset(x.ChangesetId));

            List<IWorkItemSummary> workItems = InformationNodeConverters.GetAssociatedWorkItems(buildDetail);
            WorkItemStore wis = collection.GetService<WorkItemStore>();
            IEnumerable<WorkItem> actualWorkItems = workItems.Select(x => wis.GetWorkItem(x.WorkItemId));
        }
    }
}
tf.exe history <BRANCH> /version:L<BUILD_NUMBER_FROM>~L<BUILD_NUMBER_TO> /recursive /collection:http://<our TFS server>
Changeset User              Date       Comment
--------- ----------------- ---------- -------------------------------------    ----------------
3722      Sergei Vorobiev   2013-11-16 Merge changeset 3721 from Main
3720      <redacted>
3719      <redacted>