capistrano-hivequeen 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
  require 'excon'
5
5
  require 'base64'
6
6
  require 'capistrano/hivequeen/version'
7
+ require 'capistrano/hivequeen/multiio'
7
8
 
8
9
  # Special cases:
9
10
  # - environment not found
@@ -54,6 +55,8 @@ class HiveQueen
54
55
  state = $! ? 'failed' : 'succeeded'
55
56
  puts "Finishing deployment in Hivequeen. State: #{state}"
56
57
  params = {:deployment => {:state => state}}
58
+ deploy_log = logger.device.history
59
+ params[:deployment][:deploy_log] = deploy_log if deploy_log
57
60
  put_or_post('PUT', "/environments/#{environment_id}/deployments/#{deployment_id}.json", params)
58
61
  end
59
62
 
@@ -1,4 +1,8 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
+ # Capture capistrano log output
3
+ @logger = Capistrano::Logger.new(:output => HiveQueen::MultiIO.new)
4
+ @logger.level = Capistrano::Logger::DEBUG
5
+
2
6
  HiveQueen.endpoint = hivequeen_endpoint
3
7
  HiveQueen.project = application
4
8
  HiveQueen.logger = logger
@@ -30,6 +34,11 @@ Capistrano::Configuration.instance(:must_exist).load do
30
34
  # Option to skip background tasks
31
35
  set :skip_bg, false
32
36
 
37
+ # Command to get the changes being deployed
38
+ set :changelog_command do
39
+ `git log #{current_commit}...#{real_revision} --pretty="%n%h %an: %s (%ar)" --stat --no-color`
40
+ end
41
+
33
42
  # Load capistrano multi-stage extension
34
43
  require 'fileutils' # required until https://github.com/capistrano/capistrano-ext/commit/930ca840a0b4adad0ec53546790b3f5ffe726538 is released
35
44
  require 'capistrano/ext/multistage'
@@ -40,6 +49,7 @@ Capistrano::Configuration.instance(:must_exist).load do
40
49
  HiveQueen.environments.each do |env|
41
50
  name = env['name']
42
51
  hive_queen_id = env['id']
52
+ current_commit = env['current_commit']
43
53
 
44
54
  desc "Use environment #{name}"
45
55
  task name do
@@ -52,6 +62,7 @@ Capistrano::Configuration.instance(:must_exist).load do
52
62
  set :stage, name.to_sym
53
63
  set :rails_env, name
54
64
  set :environment_id, hive_queen_id
65
+ set :current_commit, current_commit
55
66
  unless exists?(:branch)
56
67
  set :branch, environment['branch']
57
68
  end
@@ -14,11 +14,14 @@ Capistrano::Configuration.instance.load do
14
14
  task :start do
15
15
  # TODO: is there a better way to determine what cap tasks are running?
16
16
  tasks = ARGV.reject{|task_name| stage.to_s == task_name}
17
+
17
18
  params = {
18
19
  :task => tasks.join(' '),
19
20
  :commit => real_revision,
20
21
  :override => override
21
22
  }
23
+ params[:change_log] = changelog_command if current_commit
24
+
22
25
  begin
23
26
  deployment = HiveQueen.start_deployment(environment_id, params)
24
27
  set :deployment_id, deployment['id']
@@ -0,0 +1,23 @@
1
+ # Keeps an in-memory history of printed lines (to persist to HQ),
2
+ # and puts to stderr (capistrano's default)
3
+ class HiveQueen
4
+ class MultiIO
5
+ require 'stringio'
6
+
7
+ def initialize(output = $stderr)
8
+ @memory = StringIO.new
9
+ @output = output
10
+ end
11
+
12
+ def puts(msg)
13
+ [@memory, @output].each{|t| t.puts(msg)}
14
+ end
15
+
16
+ # Read the history from memory
17
+ def history
18
+ @memory.rewind
19
+ @memory.read
20
+ end
21
+
22
+ end
23
+ end
@@ -1,6 +1,6 @@
1
1
  class HiveQueen
2
2
  class Version
3
- @@version = '1.0.0'
3
+ @@version = '1.1.0'
4
4
 
5
5
  def self.to_s
6
6
  @@version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-hivequeen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-01 00:00:00.000000000 Z
12
+ date: 2012-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano-ext
16
- requirement: &70240114614400 !ruby/object:Gem::Requirement
16
+ requirement: &70268421688220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.2.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70240114614400
24
+ version_requirements: *70268421688220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: capistrano
27
- requirement: &70240114612720 !ruby/object:Gem::Requirement
27
+ requirement: &70268421687740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.11.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70240114612720
35
+ version_requirements: *70268421687740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &70240114611740 !ruby/object:Gem::Requirement
38
+ requirement: &70268421687360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70240114611740
46
+ version_requirements: *70268421687360
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: excon
49
- requirement: &70240114610620 !ruby/object:Gem::Requirement
49
+ requirement: &70268421686800 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.6.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70240114610620
57
+ version_requirements: *70268421686800
58
58
  description: Capistrano extensions for interacting with HiveQueen
59
59
  email: aaron@kickstarter.com
60
60
  executables: []
@@ -68,6 +68,7 @@ files:
68
68
  - lib/capistrano/hivequeen.rb
69
69
  - lib/capistrano/hivequeen/capistrano_configuration.rb
70
70
  - lib/capistrano/hivequeen/deploy.rb
71
+ - lib/capistrano/hivequeen/multiio.rb
71
72
  - lib/capistrano/hivequeen/setup.rb
72
73
  - lib/capistrano/hivequeen/version.rb
73
74
  homepage: http://github.com/kickstarter/capistrano-hivequeen