Skip to content

Instantly share code, notes, and snippets.

@blindsey
Last active October 20, 2016 04:23
Show Gist options
  • Save blindsey/faa67022d238067d6e6d953a498dbca3 to your computer and use it in GitHub Desktop.
Save blindsey/faa67022d238067d6e6d953a498dbca3 to your computer and use it in GitHub Desktop.
PIvotal Tracker Auto-Deliver Hotness
namespace :pivotal_tracker do
desc "deliver this projects 'finished' stories"
task :deliver do
next unless ENV['PIVOTAL_TRACKER_TOKEN']
require 'pivotal-tracker'
PivotalTracker::Client.use_ssl = true
PivotalTracker::Client.token = ENV['PIVOTAL_TRACKER_TOKEN']
project = PivotalTracker::Project.find(1786309)
stage, current, previous = fetch(:stage), fetch(:current_revision), fetch(:previous_revision)
logs = `git log #{previous}..#{current} | egrep '\\[(finish|fix)es '`
logs.scan(/(\d{9})/).flatten.uniq.each do |id|
story = project.stories.find(id)
next if story.nil?
puts ">> delivering #{story.story_type} #{story.id}"
story.update(current_state: 'delivered') if story.current_state == 'finished'
story.notes.create(text: "Deployed to #{stage}")
end
end
end
task :staging do
after :deploy, 'pivotal_tracker:deliver'
end
task :production do
after :deploy, 'pivotal_tracker:deliver'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment