cap-newrelic 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/LICENSE +20 -0
- data/README.md +59 -0
- data/cap-newrelic.gemspec +22 -0
- data/lib/cap-newrelic/tasks/cap-newrelic.rake +48 -0
- data/lib/cap-newrelic.rb +4 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 067b946ece94f30138d6b89a0b055f14b0bfd521
|
4
|
+
data.tar.gz: 7ae928943fcbf3cefae6708690472e63bc7767d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2dc7be92c6f13e2482c7ecf1dc0bfd3ee0dee640191904131ce37edbad874436664a44b228fb572f8962b193a7ba28396101964b34529e3da8c76e4b42e575fa
|
7
|
+
data.tar.gz: 75fa78e6c4a58f8d7ba2a93e70802244c65126ddeb4995f9279d53f25e437de4d1d4c2c029446b16dcc488a6106aff1bb31562ca4a4c04c4c937a27b801f1f05
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
capistrano-new-relic-*.gem
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Robert Coleman
|
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,59 @@
|
|
1
|
+
# Cap::NewRelic
|
2
|
+
|
3
|
+
New Relic Deployment API support for Capistrano 3.x
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'capistrano', '~> 3.1.0'
|
11
|
+
gem 'cap-newrelic'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install cap-newrelic
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Require the module in your `Capfile`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'cap-newrelic'
|
28
|
+
```
|
29
|
+
|
30
|
+
`cap-newrelic` comes with 1 task `newrelic:notify`.
|
31
|
+
|
32
|
+
By default the task will run after `deploy:finished`
|
33
|
+
|
34
|
+
|
35
|
+
### Configuration
|
36
|
+
|
37
|
+
Configurable options, shown here with defaults:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
set :new_relic_api_key, nil
|
41
|
+
set :new_relic_app_name, fetch(:application)
|
42
|
+
set :new_relic_url, 'https://api.newrelic.com/deployments.xml'
|
43
|
+
```
|
44
|
+
|
45
|
+
Both `new_relic_api_key` and `new_relic_app_name` are required.
|
46
|
+
If not present `new_relic_api_key` will in `ENV['NEW_RELIC_API_KEY'], `new_relic_app_name` will use the Capistrano application's name.
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
55
|
+
|
56
|
+
|
57
|
+
## Thanks
|
58
|
+
|
59
|
+
This code started out based on [https://github.com/gunnarlium/capistrano-new-relic](https://github.com/gunnarlium/capistrano-new-relic) (for Capistrano v2)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'cap-newrelic'
|
7
|
+
spec.version = '0.2.0'
|
8
|
+
spec.authors = 'Robert Coleman'
|
9
|
+
spec.email = 'github@robert.net.nz'
|
10
|
+
spec.homepage = 'http://github.com/rjocoleman/cap-newrelic'
|
11
|
+
spec.summary = 'New Relic Deployment API notification for Capistrano v3+'
|
12
|
+
spec.description = 'New Relic Deployment API notification for Capistrano v3+'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'capistrano', '~> 3.1'
|
21
|
+
spec.add_dependency 'faraday', '~> 0.9'
|
22
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
namespace :newrelic do
|
2
|
+
desc 'Notify New Relic of deployment'
|
3
|
+
task :notify do
|
4
|
+
run_locally do
|
5
|
+
current_rev = fetch(:current_revision)
|
6
|
+
previous_rev = fetch(:previous_revision)
|
7
|
+
local_user = capture('git config user.name').strip
|
8
|
+
changelog = capture("git log --oneline #{previous_rev}..#{current_rev}")
|
9
|
+
deployment = {
|
10
|
+
:deployment => {
|
11
|
+
:app_name => fetch(:new_relic_app_name) || fetch(:application),
|
12
|
+
:description => "Deploy #{fetch(:application)}/#{fetch(:branch)} to #{fetch(:stage)}",
|
13
|
+
:user => local_user,
|
14
|
+
:revision => current_rev,
|
15
|
+
:changelog => changelog
|
16
|
+
}
|
17
|
+
}
|
18
|
+
new_relic_api_key = fetch(:new_relic_api_key) || ENV['NEW_RELIC_API_KEY']
|
19
|
+
fail ":new_relic_api_key must be set - \"set :new_relic_api_key, 'yourkey'\"" unless new_relic_api_key
|
20
|
+
response = Faraday.post do |req|
|
21
|
+
req.url fetch(:new_relic_url)
|
22
|
+
req.headers['x-api-key'] = new_relic_api_key
|
23
|
+
req.body = deployment
|
24
|
+
end
|
25
|
+
if response.headers['status'] =~ /201/
|
26
|
+
info "[New Relic] Deployment created."
|
27
|
+
else
|
28
|
+
error = REXML::XPath.each(REXML::Document.new(response.body), "*/error/text()").first
|
29
|
+
info "[New Relic] #{response.headers['status']} - #{error}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
namespace :deploy do
|
37
|
+
after :finished, 'newrelic:notify'
|
38
|
+
end
|
39
|
+
|
40
|
+
namespace :load do
|
41
|
+
task :defaults do
|
42
|
+
|
43
|
+
set :new_relic_api_key, nil
|
44
|
+
set :new_relic_app_name, fetch(:application)
|
45
|
+
set :new_relic_url, 'https://api.newrelic.com/deployments.xml'
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/lib/cap-newrelic.rb
ADDED
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cap-newrelic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Coleman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-18 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: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.9'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.9'
|
41
|
+
description: New Relic Deployment API notification for Capistrano v3+
|
42
|
+
email: github@robert.net.nz
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- ".gitignore"
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
50
|
+
- cap-newrelic.gemspec
|
51
|
+
- lib/cap-newrelic.rb
|
52
|
+
- lib/cap-newrelic/tasks/cap-newrelic.rake
|
53
|
+
homepage: http://github.com/rjocoleman/cap-newrelic
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.2.0
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: New Relic Deployment API notification for Capistrano v3+
|
77
|
+
test_files: []
|
78
|
+
has_rdoc:
|