Article Image
Article Image
read

We’ve been using Ticket Poker for a while, in my current team, and we’re pretty happy with it.

Now, after each planning session, I take the stories we create in Pivotal Tracker, use a command-line script to generate a Ticket Poker ticket for each one, then paste its URL back into the Pivotal story.

Pivotal Track Story

That gets a bit repetitive, so I decided to write a script to do the work for me.

The process goes like this;

  • Find all of the development stories in the Pivotal Tracker project which haven’t been estimated yet
  • For each of those stories, check if it already has a Ticket Poker ticket
  • If it doesn’t;

In ruby, that could look something like this (assuming project is a class representing a Pivotal Tracker project, and ticket_poker is a class that exposes the Ticket Poker API);

  project
    .unestimated_stories(label: 'development')
    .each do |story|
      story.add_estimation_task(ticket_poker) unless story.has_estimation_task?
  end

The Pivotal Tracker API is really easy to use. Fetching the stories just requires GETting the stories endpoint of their latest, stable REST API.

https://www.pivotaltracker.com/services/v5/projects/$PROJECT_ID/stories

To filter for unestimated development stories, we just need to add a filter string as a querystring parameter;

label:"development" estimate:-1

We URL-encode that, and append it to the API URL as;

?filter=[encoded filter string]

To check if the story already has a Ticket Poker estimation ticket, check all the tasks belonging to the story, and see if any of them have “Ticket Poker” in their descriptions.

class Story

  ...

  def has_estimation_task?
    tasks.map(&:description).grep(/ticket.poker/i).any?
  end

  ...

end

We can get all the tasks belonging to the story by GETting the story tasks endpoint;

https://www.pivotaltracker.com/services/v5/projects/$PROJECT_ID/stories/$STORY_ID/tasks

To add a ticket estimation task to the story, we first use the Ticket Poker API to create the ticket, then POST to the Pivotal Tracker story tasks endpoint to create the new task.

class Story

  ...

  def add_estimation_task(ticket_poker)
    url = ticket_poker.create(self.url)
    @project.add_task(self, "Ticket Poker #{url}")
  end

  ...

end

Here, ticket_poker is an object that exposes the Ticket Poker API, and @project is a reference to a class representing our Pivotal Tracker project.

You can see the full script on the Ticket Poker API page (click on ‘Pivotal Tracker’ in the list of API Integration Examples).

It should be quite straightforward to follow this same pattern to integrate with any other planning tools, provided they have a suitable API. If you create any more integrations, please let me know and I’ll add them to the documentation.

Blog Logo

David Salgado


Published

Image

Ronin on Rails

Give a man a fish and he’ll eat for a day.
Give a fish a man and he’ll eat for weeks.

Back to Overview