【问题标题】:How do I use TFS object model to get the gated build definition associated with a changeset如何使用 TFS 对象模型来获取与变更集关联的门控构建定义
【发布时间】:2013-12-18 09:10:31
【问题描述】:

我想了解开发人员是否使用封闭构建进行签入。 TFS 对象模型是否允许您将签入/变更集与构建定义相关联?我最终希望能够说:

Changeset   Gated?   Build defn
-------------------------------
123          0        NULL
456          1       dev-gated-defn

【问题讨论】:

    标签: tfs tfsbuild


    【解决方案1】:

    您可以使用 TFS API 来获取此信息。下面是一个示例方法来演示如何写出您对前 7 天感兴趣的详细信息(您可以修改 MinFinishTime 以更改时间段)。

        /// <summary>
        /// Writes out information about whether gated builds are being used.
        /// </summary>
        private static void _GetBuildInsights()
        {
            using (TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false, new UICredentialsProvider()))
            {
                if (tpp.ShowDialog() == DialogResult.OK)
                {
                    TfsTeamProjectCollection projectCollection = tpp.SelectedTeamProjectCollection;
                    var buildServer = projectCollection.GetService<IBuildServer>();
    
                    var buildSpec = buildServer.CreateBuildDetailSpec(tpp.SelectedProjects[0].Name);
                    buildSpec.InformationTypes = null;
                    buildSpec.MinFinishTime = DateTime.Now.AddDays(-7);  // get last seven days of builds
    
                    IBuildDetail[] builds = buildServer.QueryBuilds(buildSpec).Builds;
    
                    Console.WriteLine("Changeset   Gated?   Build defn");
                    Console.WriteLine("-------------------------------");
    
                    foreach (IBuildDetail build in builds)
                    {
                        IBuildDefinition definition = build.BuildDefinition;
                        if (definition != null)
                        {
                            string changeset = build.SourceGetVersion.Replace("C", string.Empty);  // changesets are prefixed with "C"
                            int gated = definition.ContinuousIntegrationType == ContinuousIntegrationType.Gated ? 1 : 0;
                            Console.WriteLine("{0}         {1}        {2}", changeset, gated, definition.Name);
                        }
                    }
                }
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      • 2012-03-14
      • 2018-08-01
      • 2019-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多