capistrano-new-relic 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjhlNjE5YTRjM2I0OWMwNDIxNTU4OTRjMDc2ODFkYzY5YTlhMjc4NQ==
4
+ MDdjZjQzYTkwMWQ4Y2QxNWFkZTRlNTNhYTFhNWE4YjcwY2QyNjI4ZA==
5
5
  data.tar.gz: !binary |-
6
- YzFkOWY1N2ZjODdlYzVjYjkzOGU3ZTEyZGQ4YTIyY2QyYTc0YmVmMA==
6
+ NzhiYzk3NzhjZDEzOTQxZTY2MTE1ZjQxOWQ0NDNkYzBjNzhlODEyZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjhhNmNmYzgxNzUxY2E3MGQyYWQ5NjM5YWQ5ZjUyNzQ4OWIzNDgyZmFkMDE5
10
- NWI5OWU3ZjE2NzUzYjVkOTk4NWVjYTMzY2QzMDQxNDRjYmFiOTJkZDgzMjg3
11
- ODY4MDVkMTRhY2U0MTdlY2ExYzVkNmU3MmQ2NWJjM2I3M2Q4ZDU=
9
+ MjlmZmFkYzg4NTMxYzA5YTNhMmZiYTJmNjMxYTdmZGIxYjU3MzBmNWU0NWNj
10
+ MDI4ODBiNWMwYWFkOGQ1MDE2NzNlNzdhOWVlMjljOTU2NjJiOTUxNjhmMTQw
11
+ MTA3ZjQwYmFkYjhhYzU2OWFlZDk5NGE2NmJjODY1ZGEzN2FiMzk=
12
12
  data.tar.gz: !binary |-
13
- MDhmNTFkMTVjMDQyOWM2MmRiM2RjYTQ5YTdmODVjYjEyNGNmZDRhYzJkOGM1
14
- YWM5NzhlNmM1NjM1YjJmODMxMjE1ZmI5MmY3ZmJlYmY3ZWE5ZTUxZTAzYjQz
15
- ZTAyNjM2ZjIwNTExNzZlNGY4MzZmMTFlZmUzMTJhY2NjZTE2OTE=
13
+ NmIxNzdiOThlN2YyNWJlNzVhOTc0NDhkOTVlNmE2ZTk0ZjUxYjBlMTNmM2Zh
14
+ M2RjNzFlMGQzYmQ3Yjc2OGU3YmE4MGI1ZTNkMWM5OWFiODBlZDM2MWNlOGMy
15
+ NDJhODIxMGVhMWEzZmUyMTg1Nzk0ZTNlNjVhMTdkY2NiMzJiZDY=
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ capistrano-new-relic-*.gem
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Gunnar Lium
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # capistrano-new-relic
2
+
3
+ Capistrano recipe to notify New Relic of deployments.
4
+
5
+ This gem is inspired by https://github.com/martinj/capistrano-jenkins.
6
+
7
+ Your your name and email os fetched from git config, so make sure you have
8
+ valid values for `user.name` and `user.email`.
9
+
10
+ ## Installation
11
+
12
+ gem install capistrano-new-relic
13
+
14
+ ## Options
15
+
16
+ **:new_relic_api_key**
17
+
18
+ API key to use when posting to New Relic.
19
+
20
+ By default it will check for the API key in the environment variable NEW_RELIC_API_KEY.
21
+
22
+ ## Usage
23
+
24
+ Include the recipe
25
+
26
+ require 'capistrano-new-relic'
27
+
28
+ Set required parameters
29
+
30
+ set :application, "My Application"
31
+ set :branch, "master"
32
+ set :deploy_env, "production"
33
+ set :new_relic_api_key, "<yoursecretapikey>"
34
+
35
+
36
+ Add the task, typically after deploy
37
+
38
+ after "deploy:update_code", "newrelic:notify"
@@ -0,0 +1,19 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
2
+ require 'capistrano-new-relic/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'capistrano-new-relic'
6
+ s.version = Capistrano::NewRelic::VERSION
7
+ s.authors = ['Gunnar Lium']
8
+ s.email = ['post@gunnarlium.com']
9
+ s.homepage = 'http://github.com/gunnarlium/capistrano-new-relic'
10
+ s.summary = 'Capistrano New Relic recipe'
11
+ s.description = 'Capistrano recipe to notify New Relic after deploying code'
12
+ s.files = `git ls-files`.split($/)
13
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
14
+ s.require_paths = ['lib']
15
+ s.license = 'MIT'
16
+
17
+ s.add_dependency 'capistrano'
18
+ s.add_dependency 'colored'
19
+ end
@@ -0,0 +1,36 @@
1
+ require 'capistrano'
2
+ require 'colored'
3
+
4
+ Capistrano::Configuration.instance.load do
5
+ set(:new_relic_api_key) {
6
+ abort 'Please specify the new_relic_api_key either in :new_relic_api_key or in environment NEW_RELIC_API_KEY'.red if ENV['NEW_RELIC_API_KEY'].nil?
7
+ ENV['NEW_RELIC_API_KEY']
8
+ } unless exists? :new_relic_api_key
9
+
10
+
11
+ namespace :newrelic do
12
+ desc 'Notify New Relic of deployment'
13
+ task :notify do
14
+ abort 'Please specify :new_relic_app_name'.red unless exists? :new_relic_app_name
15
+ abort 'Please specify :deploy_env'.red unless exists? :deploy_env
16
+ local_user = run_locally('git config user.name').strip
17
+ local_user_email = run_locally('git config user.email').strip
18
+ current_rev = capture("cd #{latest_release}; git rev-parse HEAD").strip
19
+ previous_rev = capture("cd #{previous_release}; git rev-parse HEAD").strip
20
+ changelog = capture("cd #{latest_release}; git log --oneline #{previous_rev}..#{current_rev}")
21
+ tmp_file_name = "#{current_rev}-#{previous_rev}-changelog"
22
+ File.open(tmp_file_name, 'w') { |file| file.write("deployment[changelog]=#{changelog}")}
23
+ run_locally %Q{\
24
+ curl -s -H "x-api-key:#{new_relic_api_key}"\
25
+ -d "deployment[app_name]=#{new_relic_app_name}"\
26
+ -d "deployment[description]=Deploy #{application}/#{branch} to #{deploy_env}"\
27
+ -d "deployment[user]=#{local_user} <#{local_user_email}>"\
28
+ -d "deployment[revision]=#{current_rev}"\
29
+ --data-binary @#{tmp_file_name}\
30
+ https://rpm.newrelic.com/deployments.xml\
31
+ > /dev/null 2>&1\
32
+ }
33
+ File.unlink(tmp_file_name)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module NewRelic
3
+ VERSION = '0.0.5'
4
+ end
5
+ end
@@ -1,45 +1 @@
1
- # encoding: utf-8
2
- require 'capistrano'
3
- require 'colored'
4
-
5
- def _cset(name, *args, &block)
6
- unless exists?(name)
7
- set(name, *args, &block)
8
- end
9
- end
10
-
11
- Capistrano::Configuration.instance.load do
12
- _cset(:new_relic_api_key) {
13
- abort "Please specify the new_relic_api_key either in :new_relic_api_key or in environment NEW_RELIC_API_KEY".red if ENV['NEW_RELIC_API_KEY'].nil?
14
- ENV['NEW_RELIC_API_KEY']
15
- }
16
-
17
- _cset(:new_relic_app_name) { abort "Please specify :newrelic_app_name".red }
18
- _cset(:deploy_env) { abort "Please specify :deploy_env, needed for sensible description".red }
19
- _cset(:application) { abort "Please specify :application, needed for sensible description".red }
20
- _cset(:branch) { abort "Please specify :branch, needed for sensible description".red }
21
-
22
- namespace :newrelic do
23
- desc "Notify New Relic of deployment"
24
- task :notify do
25
- local_user = run_locally("git config user.name").strip
26
- local_user_email = run_locally("git config user.email").strip
27
- current_rev = capture("cd #{latest_release}; git rev-parse HEAD").strip()
28
- previous_rev = capture("cd #{previous_release}; git rev-parse HEAD").strip()
29
- changelog = capture("cd #{latest_release}; git log --oneline #{previous_rev}..#{current_rev}")
30
- tmp_file_name = current_rev + '-' + previous_rev + '-changelog'
31
- File.open(tmp_file_name, 'w') { |file| file.write("deployment[changelog]=#{changelog}")}
32
- run_locally %Q{\
33
- curl -s -H "x-api-key:#{new_relic_api_key}"\
34
- -d "deployment[app_name]=#{new_relic_app_name}"\
35
- -d "deployment[description]=Deploy #{application}/#{branch} to #{deploy_env}"\
36
- -d "deployment[user]=#{local_user} <#{local_user_email}>"\
37
- -d "deployment[revision]=#{current_rev}"\
38
- --data-binary @#{tmp_file_name}\
39
- https://rpm.newrelic.com/deployments.xml\
40
- > /dev/null 2>&1\
41
- }
42
- File.unlink(tmp_file_name)
43
- end
44
- end
45
- end
1
+ require 'capistrano-new-relic/capistrano-new-relic'
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-new-relic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gunnar Lium
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-08 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2013-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colored
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: Capistrano recipe to notify New Relic after deploying code
14
42
  email:
15
43
  - post@gunnarlium.com
@@ -17,7 +45,13 @@ executables: []
17
45
  extensions: []
18
46
  extra_rdoc_files: []
19
47
  files:
48
+ - .gitignore
49
+ - LICENSE
50
+ - README.md
51
+ - capistrano-new-relic.gemspec
20
52
  - lib/capistrano-new-relic.rb
53
+ - lib/capistrano-new-relic/capistrano-new-relic.rb
54
+ - lib/capistrano-new-relic/version.rb
21
55
  homepage: http://github.com/gunnarlium/capistrano-new-relic
22
56
  licenses:
23
57
  - MIT