Created
April 26, 2016 15:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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