-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_all_tracker_stories.rb
30 lines (21 loc) · 1.03 KB
/
delete_all_tracker_stories.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'rubygems'
require 'nokogiri'
TOKEN = '1234' # put your token here
PROJECT_ID = '82277' # project ID goes here
STORY_COMMAND = %[curl -H "X-TrackerToken: #{TOKEN}" -X GET http://www.pivotaltracker.com/services/v3/projects/#{PROJECT_ID}/stories]
PROJECT_INFO= %[curl -H "X-TrackerToken: #{TOKEN}" -X GET http://www.pivotaltracker.com/services/v3/projects/#{PROJECT_ID}]
xml = Nokogiri::XML(`#{STORY_COMMAND}`)
project_xml = Nokogiri::XML(`#{PROJECT_INFO}`)
project_name = project_xml.search('project').map { |node| node.at('name').text}
puts " --------------------------------- Are you SURE you want to delete #{project_name}? y or n ---------------------------------"
confirm_delete = gets.chomp
if confirm_delete == "y"
ids = xml.search('story').map { |node| node.at('id').text }
ids.each do |id|
`curl -H "X-TrackerToken: #{TOKEN}" -X DELETE http://www.pivotaltracker.com/services/v3/projects/#{PROJECT_ID}/stories/#{id}`
puts "deleted story: #{id}"
end
else
puts "Nothing will be deleted. Have a nice day."
exit
end