Sha256: d8cf4227ade55cc211af13c5a9aa115e47ea293067fb4347910bf46a57546a8d
Contents?: true
Size: 1 KB
Versions: 17
Compression:
Stored size: 1 KB
Contents
#!/usr/bin/env ruby require('json') require('ostruct') require('rest-client') stream = ARGV.any? ? ARGV : ARGF if stream == ARGF && $stdin.tty? puts "Usage: deliver-story STORY_INFO_JSON" puts "Examples:\n deliver-story '{\"id\":123,\"current_state\":\"started\"}'" puts %Q[ echo '{"id":123,"current_state":"started"}' | deliver-story] exit 1 end stream.each do |story_hash| story = OpenStruct.new(JSON.parse(story_hash)) story_state = story.current_state if story_state != 'finished' puts "Story #{story.id} is not finished, not delivering" next end story_url = "https://www.pivotaltracker.com/services/v5/stories/#{story.id}" begin response = RestClient::Request.execute( method: :put, url: story_url, payload: {current_state: 'delivered'}, headers: {'X-TrackerToken' => ENV['PIVOTAL_TRACKER_API_TOKEN']} ) puts response rescue RestClient::Exception => e puts "Error delivering story #{story.id}, #{e.message}:\n#{e.backtrace.join("\n")}" end end
Version data entries
17 entries across 17 versions & 1 rubygems