Team Foundation Server内のタスクをTrelloと統合する方法はありますか?


12

Trelloを既存の開発環境に統合できるかどうかを判断しようとしています。現在、Team Foundation Serverをソースコード管理リポジトリとして使用していますが、TFS内のタスクをリンクしてTrelloのボード上のアイテムを一覧表示したいのですが、これはリモートでも可能ですか?APIが用意されていることは知っていますが、主に誰かがこのような統合を試みたことがあるかどうかを主に知りたいと思っています。これが可能であれば、Trelloは基本的にTFSへのユーザーインターフェイスになります。

回答:


9

以下のプログラムは、TrelloカードからTFSタスクを作成します。Trelloチェックリストは、タスクアイテムの説明として表示されます。

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using TrelloNet;

namespace TFSTrelloAPI
{
    class Program
    {
        #region Trello Security
        public static string DevTeamTasksBoardId { get; set; }
        public static string TrelloToken { get; set; }
        public static string TrelloKey { get; set; }
        #endregion

        #region TFS Details
        public static string TFSProject { get; set; }
        public static string TFSServerUri { get; set; }
        public static Uri Url { get; set; }
        #endregion

        static void Main(string[] args)
        {
            SetTrelloSecurity();
            SetTFSDetails();
            ITrello trello = new Trello(TrelloKey);
            IList<string> lines = new List<string>();
            Url = trello.GetAuthorizationUrl("TFSImport", Scope.ReadOnly);
            trello.Authorize(TrelloToken);
            var boards = trello.Boards;
            foreach (var board in boards.ForMe())
            {
                if (board.Id == DevTeamTasksBoardId)
                {
                    lines.Add("Name: " + board.Name);
                    lines.Add(" Desc: " + board.Desc);
                    lines.Add("ID: " + board.Id);
                }
            }
            IBoardId bid = new BoardId(DevTeamTasksBoardId);

            var lists = trello.Lists.ForBoard(bid);
            foreach (var list in lists)
            {
                var listId = new ListId(list.Id);
                var cards = trello.Cards.ForList(listId);
                foreach (var card in cards)
                {
                    var sbTaskDesc = new StringBuilder();
                    string taskName = (card.Name + " * Desc: " + card.Desc);
                    ICardId ic = new CardId(card.Id);
                    var chkLists = trello.Checklists.ForCard(ic);
                    foreach (var checklist in chkLists)
                    {
                        sbTaskDesc.AppendLine(" * " + checklist.Name);
                        sbTaskDesc.AppendLine(" * ");
                        var ckItems = checklist.CheckItems;
                        foreach (var checkItem in ckItems)
                        {
                            sbTaskDesc.AppendLine(" * " + checkItem.Name);
                        }
                    }
                    string taskDesc = sbTaskDesc.ToString();
                    CreateTask(taskName, taskDesc);
                }
            }
        }


    /// <summary>
        /// Replace empty strings with specific TFS information
        /// </summary>
        private static void SetTFSDetails()
        {
            TFSServerUri = string.Empty;
            TFSProject = string.Empty;
            Url = new Uri(TFSServerUri);
        }
        /// <summary>
        /// Replace empty strings with values from your Trello 
        /// See TrelloAPI documentaiotn for details
        /// </summary>
        private static void SetTrelloSecurity()
        {
            DevTeamTasksBoardId = string.Empty;
            TrelloToken = string.Empty;
            TrelloKey = string.Empty;
        }
        private static void CreateTask(string taskName, string taskDesc)
        {
            // Connect to the server and the store, and get the WorkItemType object
            // for user stories from the team project where the user story will be created. 
            var collectionUri = new Uri(TFSServerUri);
            var tpc = new TfsTeamProjectCollection(collectionUri);
            var workItemStore = tpc.GetService<WorkItemStore>();
            Project teamProject = workItemStore.Projects[TFSProject];
            WorkItemType workItemType = teamProject.WorkItemTypes["Task"];

            // Create the work item. 
            var userStory = new WorkItem(workItemType)
            {
                // The title is the only required field that does not have a default value. 
                // You must set it, or you cannot save the work item. 
                Title = taskName.Length > 255 ? taskName.Substring(0, 254) : taskName, // max length for name 255 char
                Description = taskDesc
            };

            // Save the new user story. 
            userStory.Save();
        }

    }
}

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.