Skip to content

Commit b16dc3c

Browse files
author
Senthil
committed
add script to auto deliver stories
1 parent f90934c commit b16dc3c

4 files changed

Lines changed: 89 additions & 1 deletion

File tree

scripts/Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# A sample Gemfile
2+
source "https://rubygems.org"
3+
4+
gem "pivotal-tracker"

scripts/Gemfile.lock

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
builder (3.2.2)
5+
crack (0.4.2)
6+
safe_yaml (~> 1.0.0)
7+
domain_name (0.5.25)
8+
unf (>= 0.0.5, < 1.0.0)
9+
http-cookie (1.0.2)
10+
domain_name (~> 0.5)
11+
mime-types (2.6.2)
12+
mini_portile (0.6.2)
13+
netrc (0.11.0)
14+
nokogiri (1.6.6.2)
15+
mini_portile (~> 0.6.0)
16+
nokogiri-happymapper (0.5.9)
17+
nokogiri (~> 1.5)
18+
pivotal-tracker (0.5.13)
19+
builder
20+
crack
21+
nokogiri (>= 1.5.5)
22+
nokogiri-happymapper (>= 0.5.4)
23+
rest-client (>= 1.8.0)
24+
rest-client (1.8.0)
25+
http-cookie (>= 1.0.2, < 2.0)
26+
mime-types (>= 1.16, < 3.0)
27+
netrc (~> 0.7)
28+
safe_yaml (1.0.4)
29+
unf (0.1.4)
30+
unf_ext
31+
unf_ext (0.0.7.1)
32+
33+
PLATFORMS
34+
ruby
35+
36+
DEPENDENCIES
37+
pivotal-tracker
38+
39+
BUNDLED WITH
40+
1.10.6

scripts/deliver-pivotal-stories.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env ruby
2+
3+
require "pivotal-tracker"
4+
5+
begin
6+
TRACKER_TOKEN = ENV["PIVOTAL_TOKEN"]
7+
PROJECTS = ENV["PIVOTAL_PROJECTS"]
8+
9+
if TRACKER_TOKEN.nil?
10+
throw "Error: expected non empty 'PIVOTAL_TOKEN' env variable."
11+
end
12+
13+
if PROJECTS.nil?
14+
throw "Error: expected non empty 'PIVOTAL_PROJECTS' env variable."
15+
end
16+
17+
PivotalTracker::Client.token = TRACKER_TOKEN
18+
PivotalTracker::Client.use_ssl = true
19+
20+
PROJECTS.split(",").each do |project_id|
21+
project = PivotalTracker::Project.find(project_id)
22+
stories = project.stories.all(state: "finished", story_type: ["bug", "feature"])
23+
24+
sandbox_tag = "sandbox-deployment"
25+
26+
stories.each do | story |
27+
search_result = `git log --merges --grep "\##{story.id}" #{sandbox_tag}`
28+
if search_result.length > 0
29+
puts "Found #{story.id}, marking as delivered."
30+
31+
story.notes.create(:text => "Delivered by sandbox deploy script.")
32+
story.update({"current_state" => "delivered"})
33+
else
34+
puts "Could not find #{story.id} in git repo."
35+
end
36+
end
37+
end
38+
rescue => e
39+
puts "Error: #{e}"
40+
exit(0) # exit without error so as to not break deploy
41+
end

wercker.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
box: koding/base@0.0.20
1+
box: koding/base@0.0.24
22
no-response-timeout: 10
33
services:
44
- userminddeployer/postgresql9.3@0.0.7-usermind-9.3-1
@@ -237,6 +237,9 @@ deploy:
237237
./scripts/install-npm.sh -d client -u
238238
239239
make -C client dist
240+
- script:
241+
name: pivotal deliver stories
242+
code: $WERCKER_ROOT/scripts/deliver-pivotal-stories.rb
240243
- script:
241244
name: zip
242245
code: |

0 commit comments

Comments
 (0)