Trello with Visual Studio Team Services

Last Update: 3/6/2017

Create cards and lists in Trello in response to events from Visual Studio Team Services. For example, when code is pushed, or a build occurs.

Get a Trello authorization token

  1. If you don't have a Trello account, get one here.

  2. Go to the Authorize Visual Studio Team Services for Trello page, and sign in with your Trello credentials.

  3. Allow Visual Studio Team Services to use your Trello account.

    Allow Visual Studio Team Services

  4. Copy the authorization token.

    Trello athorization token

Create a Trello card or list from a Visual Studio Team Services event

  1. From your team project's home page, go to the administration page.

    Administration icon on the team project home page

  2. In the Service Hooks tab, add a subscription.

    Service hooks tab, create subscription link

  3. Pick the Trello service.

    Service page, Trello selected

  4. Configure the triggering Visual Studio event. In this case, we're going to have the subscription respond when a work item is created.

    Trigger configuration page

  5. Set up the action that Trello will take in response to the trigger - either create a card or a list.

    Action configuration page

    You can use placeholders to insert content from the event into the name and description of the cards or lists that the subscription creates. For example, when we run the test notification, the card that gets created is named "Bug #5: Some great new idea!" because the test work item is a bug (ID=5) with the title "Some great new idea!".

  6. Test the service hook subscription and finish the wizard.

    Test notification

Now its setup. Go to Trello and see the cards appear.

Welcome board with a card for Bug #5

Placeholders

You can insert placeholders in the name of a list or the name or description of a card to be created by your subscription. When a list or card is created, the placeholders will be replaced by values from the event that was raised. The example we used for the card name in this page uses:

    {{workitem.workItemType}} #{{workitem.id}}: {{workitem.title}}

So when a bug is created with the ID 5 and title "Some great new idea!", the card name is "Bug #5: Some great new idea!".

The basic form of the placeholder is {{resource.field}} where resource is the name of the resource raising the event (workitem, build, etc) and field is a field within the resource section of the event, like id. So, if the subscription were for a completed build, it might be something like

    Build {{build.id}} completed at {{build.finishTime}}

To understand what fields are available to use, look at the events reference.

Work item fields

Work item fields appear in the event in the fields array, like this:

    " fields": {
                " System.AreaPath": "Fabrikam-Fiber-Git", 
                " System.TeamProject": "Fabrikam-Fiber-Git", 
                " System.IterationPath": "Fabrikam-Fiber-Git", 
                " System.WorkItemType": "Product Backlog Item", 
                " System.State": "New", 
                " System.Reason": "New backlog item", 
                " System.CreatedDate": "2014-11-05T21:11:28.85Z", 
                " System.CreatedBy": "Normal Paulk", 
                " System.ChangedDate": "2014-11-05T21:11:29.23Z", 
                " System.ChangedBy": "Normal Paulk", 
                " System.Title": "Test PBI", 
                " Microsoft.VSTS.Common.BacklogPriority": 999999999, 
                " WEF_6CB513B6E70E43499D9FC94E5BBFB784_Kanban.Column": "New"
           },

Working directly from the event definition, we would have created our card name like this:

    {{workitem.fields["System.workItemType"]}} #{{workitem.fields["System.id"]}: {{workitem.fields["System.title"]}}

As a shortcut, you can reference any fields in the System or Microsoft.VSTS.Common namespaces as if they were fields of the resource. So {{workitem.fields["System.workItemType"]}} becomes {{workitem.workItemType}}.

Placeholder expressions

These placeholders use a (handlebars templates)[http://handlebarsjs.com/] implementation that is largely compatible with Mustache. Some useful expressions include

Type of expression examples
basic expressions {{workitem.name}}
array expressions {{pullRequest.reviewers.[0].displayName}}
Mustache sections {{#workitem.assignedTo}} This WI is assigned {{/workitem.assignedTo}}
Mustache Inverted Sections {{^workitem.assignedTo}} This WI is not assigned {{/workitem.assignedTo}}
Handlebars block helpers with
if/else
unless
each
Handlerbars paths ...
this
For example, {{../comment/id}} or {{this/title}}
Template comments {{!-- this is a handlebar comment --}}

Q & A

Q: Can I programmatically create subscriptions?

A: Yes, see details here.

Q: Can I get more information about Trello?

A: Yes, trello.com.