cijoe 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/cijoe CHANGED
@@ -2,6 +2,7 @@
2
2
  $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
3
3
 
4
4
  require 'choice'
5
+ require 'cijoe'
5
6
 
6
7
  Choice.options do
7
8
  banner "Usage: #{File.basename(__FILE__)} [-hpv] path_to_git_repo"
@@ -46,6 +47,4 @@ end
46
47
 
47
48
  options = Choice.choices
48
49
 
49
- require 'cijoe'
50
-
51
- CIJoe::Server.start(options[:host], options[:port], File.expand_path(Choice.rest[0]))
50
+ CIJoe::Server.start(options[:host], options[:port], File.expand_path(Choice.rest[0].to_s))
@@ -127,10 +127,11 @@ class CIJoe
127
127
  output = ''
128
128
  git_update
129
129
  build.sha = git_sha
130
+ build.branch = git_branch
130
131
  write_build 'current', build
131
132
 
132
133
  open_pipe("cd #{@project_path} && #{runner_command} 2>&1") do |pipe, pid|
133
- puts "#{Time.now.to_i}: Building #{build.short_sha}: pid=#{pid}"
134
+ puts "#{Time.now.to_i}: Building #{build.branch} at #{build.short_sha}: pid=#{pid}"
134
135
 
135
136
  build.pid = pid
136
137
  write_build 'current', build
@@ -139,6 +140,7 @@ class CIJoe
139
140
 
140
141
  Process.waitpid(build.pid, 1)
141
142
  status = $?.exitstatus.to_i
143
+ @current_build = build
142
144
  puts "#{Time.now.to_i}: Built #{build.short_sha}: status=#{status}"
143
145
 
144
146
  status == 0 ? build_worked(output) : build_failed('', output)
@@ -187,10 +189,9 @@ class CIJoe
187
189
  {}
188
190
  end
189
191
 
192
+ ENV.clear
190
193
  data.each{ |k, v| ENV[k] = v }
191
- ret = `cd #{@project_path} && sh #{file}`
192
- data.each{ |k, v| ENV[k] = nil }
193
- ret
194
+ `cd #{@project_path} && sh #{file}`
194
195
  end
195
196
  end
196
197
 
@@ -1,7 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
3
  class CIJoe
4
- class Build < Struct.new(:project_path, :user, :project, :started_at, :finished_at, :sha, :status, :output, :pid)
4
+ class Build < Struct.new(:project_path, :user, :project, :started_at, :finished_at, :sha, :status, :output, :pid, :branch)
5
5
  def initialize(*args)
6
6
  super
7
7
  self.started_at ||= Time.now
@@ -52,7 +52,7 @@ class CIJoe
52
52
  end
53
53
 
54
54
  def dump(file)
55
- config = [user, project, started_at, finished_at, sha, status, output, pid]
55
+ config = [user, project, started_at, finished_at, sha, status, output, pid, branch]
56
56
  data = YAML.dump(config)
57
57
  File.open(file, 'wb') { |io| io.write(data) }
58
58
  end
@@ -27,8 +27,10 @@ class CIJoe
27
27
  end
28
28
 
29
29
  post '/?' do
30
- payload = YAML.load(params[:payload].to_s) || {}
31
- pushed_branch = payload['ref'].to_s.split('/').last
30
+ payload = params[:payload].to_s
31
+ if payload =~ /"ref":"(.+?)"/
32
+ pushed_branch = $1.split('/').last
33
+ end
32
34
 
33
35
  # Only build if we were given an explicit branch via `?branch=blah`,
34
36
  # no payload exists (we're probably testing), or the payload exists and
@@ -86,6 +88,11 @@ class CIJoe
86
88
  CIJoe::Server.run! :host => host, :port => port
87
89
  end
88
90
 
91
+ def self.rack_start(project_path)
92
+ set :project_path, project_path
93
+ self.new
94
+ end
95
+
89
96
  def self.project_path=(project_path)
90
97
  user, pass = Config.cijoe(project_path).user.to_s, Config.cijoe(project_path).pass.to_s
91
98
  if user != '' && pass != ''
@@ -1,3 +1,3 @@
1
1
  class CIJoe
2
- Version = VERSION = "0.8.1"
2
+ Version = VERSION = "0.9.0"
3
3
  end
@@ -19,7 +19,7 @@
19
19
  <li>
20
20
  <span class="date"><%= pretty_time(joe.current_build.started_at) if joe.current_build %></span> &raquo;
21
21
  <% if joe.current_build.sha %>
22
- Building <a href="<%= joe.current_build.commit.url %>"><%= joe.current_build.short_sha %></a> <small>(pid: <%= joe.pid %>)</small>
22
+ Building <%= joe.current_build.branch %> at <a href="<%= joe.current_build.commit.url %>"><%= joe.current_build.short_sha %></a> <small>(pid: <%= joe.pid %>)</small>
23
23
  <% else %>
24
24
  Build starting...
25
25
  <% end %>
@@ -32,7 +32,7 @@
32
32
  <li>
33
33
  <span class="date"><%= pretty_time(joe.last_build.finished_at) %></span> &raquo;
34
34
  <% if joe.last_build.sha %>
35
- Built <a href="<%= joe.last_build.commit.url %>"><%= joe.last_build.short_sha %></a>
35
+ Built <%= joe.last_build.branch %> at <a href="<%= joe.last_build.commit.url %>"><%= joe.last_build.short_sha %></a>
36
36
  <% end %>
37
37
  <span class="<%= joe.last_build.status %>">(<%= joe.last_build.status %>)</span>
38
38
  <% if joe.last_build.duration %>
@@ -49,10 +49,10 @@
49
49
  <div class="footer">
50
50
  <div class="contact">
51
51
  <p>
52
- <a href="http://github.com/defunkt/cijoe/tree/master#readme">Documentation</a><br/>
53
- <a href="http://github.com/defunkt/cijoe">Source</a><br/>
54
- <a href="http://github.com/defunkt/cijoe/issues">Issues</a><br/>
55
- <a href="http://twitter.com/defunkt">Twitter</a>
52
+ <a href="https://github.com/defunkt/cijoe#readme">Documentation</a><br/>
53
+ <a href="https://github.com/defunkt/cijoe">Source</a><br/>
54
+ <a href="https://github.com/defunkt/cijoe/issues">Issues</a><br/>
55
+ <a href="https://github.com/defunkt/cijoe/tree/v<%= CIJoe::VERSION %>">v<%= CIJoe::VERSION %></a>
56
56
  </p>
57
57
  </div>
58
58
  <div class="contact">
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cijoe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 8
9
- - 1
10
- version: 0.8.1
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Wanstrath
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-06 00:00:00 -08:00
18
+ date: 2011-02-08 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency