The scene: Pivotal NYC. Jeff Dean walks up to Dan Podsedly, manager of Pivotal Tracker development.
Jeff: Hey Dan, you asked what features we wanted in Tracker. How about a way to automatically mark all my Finished stories as Delivered, all at once?
Dan: (with a sly smile) Well, we have an API call for it.
Thus was born my humble capistrano task which marks all your Finished stories as Delivered. Hook it into your demo deploy task and save yourself some time.
As an added bonus, if you have Paul Dix’s sax-machine gem installed (it’s a SAX object parser that uses nokogiri, which I co-wrote with Aaron Patterson), you’ll even get a brief summary report of the delivered stories in your cap output.
The code is below (you’ll need to generate a Tracker API key). Now go deliver some stories!
#
# To use this task, simply set the following variables:
#
# set :pivotal_tracker_project_id, PROJECT_ID
# set :pivotal_tracker_token, TOKEN
#
# Then, inside the task for your demo platform, add
#
# task :demo do
# ...
# after :deploy, 'pivotal_tracker:deliver_stories'
# end
#
namespace :pivotal_tracker do
desc "deliver your project's 'finished' stories"
task :deliver_stories do
require 'rubygems'
require 'activeresource'
class Story < ActiveResource::Base
self.site = "http://www.pivotaltracker.com/services/v2/projects/:project_id"
end
Story.headers['X-TrackerToken'] = pivotal_tracker_token
puts "* delivering tracker stories ..."
response = Story.put(:deliver_all_finished, :project_id => pivotal_tracker_project_id)
begin
require 'sax-machine'
class Story
include SAXMachine
element :name
element :story_type
element :estimate
element :description
end
class Stories
include SAXMachine
elements :story, :as => :stories, :class => Story
end
doc = Stories.parse(response.body)
puts "* delivered #{doc.stories.length} stories"
doc.stories.each do |story|
puts " - #{story.story_type}: #{story.name} (#{story.estimate} points)"
end
rescue LoadError => e
puts "* stories delivered."
end
end
end