Skip to content

Instantly share code, notes, and snippets.

@lurecas
Forked from palcalde/update_pivotal.rb
Created April 26, 2016 15:45
Show Gist options
  • Save lurecas/53047eaa657b63a3c3155dd32aab05fc to your computer and use it in GitHub Desktop.
Save lurecas/53047eaa657b63a3c3155dd32aab05fc to your computer and use it in GitHub Desktop.
Update pivotal stories that are marked as finished to be delivered when their ID is found in the git commit history
#!/usr/bin/env ruby
require 'pivotal-tracker'
PivotalTracker::Client.token = ENV["PIVOTAL_TRACKER_TOKEN"]
PivotalTracker::Client.use_ssl = true
projects = PivotalTracker::Project.find(ENV["TRACKER_PROJECT_ID"])
stories = projects.stories.all(:state => "finished", :story_type => ['bug', 'feature'])
app_version = ENV["APP_VERSION"] ? ENV["APP_VERSION"] : `git tag | grep v | tail -n1`
app_short_version = ENV["APP_SHORT_VERSION"]
stories.each do | story |
search_result = `git log --grep #{story.id}`
if search_result.length > 0
puts "Found #{story.id}, marking as delivered."
story.notes.create(:text => "Delivered by staging deploy script.")
story.tasks.create(:description => "TODO: Test in version #{app_version}")
story.update({"current_state" => "delivered"})
story.update({"labels" => "#{app_short_version}"}) unless app_short_version.to_s.empty?
else
puts "Coult not find finished story #{story.id} in any commit message."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment