Skip to content

Instantly share code, notes, and snippets.

@palcalde
Created April 26, 2016 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save palcalde/3b61b345fc52d58d3ea81c3513567477 to your computer and use it in GitHub Desktop.
Save palcalde/3b61b345fc52d58d3ea81c3513567477 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