capistrano-isitdeployed 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -9
- data/lib/capistrano/isitdeployed/config.rb +1 -1
- data/lib/capistrano/isitdeployed/version.rb +1 -1
- data/lib/capistrano/isitdeployed.rb +28 -52
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA512:
|
3
|
-
data.tar.gz:
|
4
|
-
metadata.gz:
|
3
|
+
data.tar.gz: f911d28496a65239126bcc19f20569e144dcc6ac5136b9cb1181ac43484dea78cd5d42d0472ce840f7e8cabd498614f7532b7f75fb28f5ac6af98f53a95f88a8
|
4
|
+
metadata.gz: f523e801dd6b293a687b57a4dac839d21736df87fe6d5532a6358c597c3eda5d3325c9d7d4141b8ed6d223cefa45c5c36c771deb98a1c8f2975ef71872181aef
|
5
5
|
SHA1:
|
6
|
-
data.tar.gz:
|
7
|
-
metadata.gz:
|
6
|
+
data.tar.gz: 85aa8b4ea01716a5fc5a8af7c347b8ec80373dd5
|
7
|
+
metadata.gz: c7c593ac375e3eb57d4edb16223fae2901bb5311
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
This plugin works as an interface between your [Capistrano](http://capistranorb.com/) deployments and [www.isitdeployed.com](http://www.isitdeployed.com) which gives you :
|
4
4
|
* deployments counter for your projects
|
5
5
|
* a deployment status page for you and your team which displays current deploy status (does not nead page reload for updates)
|
6
|
-
* soon
|
6
|
+
* soon: deploys statistics
|
7
7
|
|
8
8
|
And it's Free.
|
9
9
|
|
@@ -12,11 +12,16 @@ If not, you should! :-)
|
|
12
12
|
|
13
13
|
Has been tested with Rails3 and Symfony2 projects.
|
14
14
|
|
15
|
+
## Requirements
|
16
|
+
* some gems but dependencies are managed automatically when you install capistrano-isitdeployed
|
17
|
+
* ruby1.x**-dev** (otherwise you will get `no such file to load -- mkmf (LoadError)`)
|
18
|
+
* log level must display `logger.trace`
|
19
|
+
|
15
20
|
## Installation
|
16
21
|
|
17
22
|
* install the gem
|
18
23
|
* create a project on [www.isitdeployed.com](http://www.isitdeployed.com) with a valid email address
|
19
|
-
* you will receive the instructions to enable capistrano-isitdeployed in
|
24
|
+
* you will receive the instructions to enable capistrano-isitdeployed in your project
|
20
25
|
|
21
26
|
## Detailed installation
|
22
27
|
|
@@ -34,14 +39,14 @@ and run:
|
|
34
39
|
`gem install capistrano-isitdeployed`
|
35
40
|
(you may have to use sudo)
|
36
41
|
|
37
|
-
### 2. at the top of `config/deploy.rb`, add:
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
### 2. at the top of `config/deploy.rb`, add the lines you received on your email:
|
43
|
+
# isitdeplopyed settings
|
44
|
+
require 'capistrano/isitdeployed'
|
45
|
+
set :isitdeployed_project_id, 'x'
|
46
|
+
set :isitdeployed_api_secret, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
42
47
|
|
43
|
-
###
|
44
|
-
|
48
|
+
### 3. Deploy!
|
49
|
+
cap deploy
|
45
50
|
|
46
51
|
## Contributing
|
47
52
|
|
@@ -18,7 +18,7 @@ module Capistrano
|
|
18
18
|
|
19
19
|
def self.load_into(configuration)
|
20
20
|
configuration.load do
|
21
|
-
|
21
|
+
|
22
22
|
# task hooks
|
23
23
|
before 'deploy', 'isit:deploy'
|
24
24
|
after 'deploy', 'isit:status:success'
|
@@ -28,57 +28,34 @@ module Capistrano
|
|
28
28
|
|
29
29
|
# task definitions
|
30
30
|
namespace :isit do
|
31
|
-
# TODO: generate a pre-configured file using command line arguments
|
32
|
-
# cap isit-setup -project_id=x -api_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
33
|
-
desc "Creates a configuration file"
|
34
|
-
task :setup do
|
35
|
-
if File.exists?(CONFIG_DEST)
|
36
|
-
logger.trace "WARNING: A configuration file already exists. Remove it before running setup again."
|
37
|
-
else
|
38
|
-
path = File.dirname(File.expand_path(__FILE__))
|
39
|
-
source = path + '/isitdeployed/' + CONFIG_SRC
|
40
|
-
dest = CONFIG_DEST
|
41
|
-
FileUtils.cp source, dest
|
42
|
-
logger.trace "IsItDeployed > #"
|
43
|
-
logger.trace "IsItDeployed > # A configuration file '#{dest}' has been created."
|
44
|
-
logger.trace "IsItDeployed > # Please edit this file before your next deploy."
|
45
|
-
logger.trace "IsItDeployed > #"
|
46
|
-
end
|
47
|
-
end
|
48
31
|
|
49
32
|
desc "Creates a new deploy using the API"
|
50
33
|
task :deploy do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
if json['latest_version'] > VERSION
|
62
|
-
logger.trace "IsItDeployed > WARNING: Your 'capistrano-isitdeployed' gem is outdated. Consider upgrade to #{json['latest_version']}"
|
63
|
-
end
|
64
|
-
set(:isitdeployed_did, json['deploy_id'])
|
65
|
-
set(:isitdeployed_started, started)
|
66
|
-
set(:isitdeployed_created, 1)
|
67
|
-
when 401
|
68
|
-
logger.trace "IsItDeployed > ERROR: Invalid 'api_secret'. Check your '#{CONFIG_DEST}'"
|
69
|
-
set(:isitdeployed_created, 0)
|
70
|
-
when 404
|
71
|
-
logger.trace "IsItDeployed > ERROR: Invalid 'project_id'. Check your '#{CONFIG_DEST}'"
|
72
|
-
set(:isitdeployed_created, 0)
|
73
|
-
else
|
74
|
-
logger.trace "IsItDeployed > ERROR: Can't create deploy, server returned code #{response.code}"
|
75
|
-
set(:isitdeployed_created, 0)
|
34
|
+
started = Capistrano::Isitdeployed.timestamp
|
35
|
+
set(:stage, "my platform") unless exists?(:stage)
|
36
|
+
RestClient.post(ENDPOINT + "/p/#{isitdeployed_project_id}/d", JSON.generate({ :status => 1, :platform => "#{stage}", :release => "#{release_name}", :started => started, :token => isitdeployed_api_secret, :version => VERSION }), :content_type => :json, :accept => :json, :timeout => 5, :open_timeout => 5){ |response, request, result| response
|
37
|
+
case response.code
|
38
|
+
when 201
|
39
|
+
logger.trace "IsItDeployed > New deploy created for #{application} to #{stage} with version: #{release_name}"
|
40
|
+
logger.trace "IsItDeployed > URL is #{ENDPOINT}/p/#{isitdeployed_project_id}"
|
41
|
+
json = JSON.parse(response)
|
42
|
+
if json['latest_version'] > VERSION
|
43
|
+
logger.trace "IsItDeployed > WARNING: Your 'capistrano-isitdeployed' gem is outdated. Consider upgrade to #{json['latest_version']}"
|
76
44
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
45
|
+
set(:isitdeployed_did, json['deploy_id'])
|
46
|
+
set(:isitdeployed_started, started)
|
47
|
+
set(:isitdeployed_created, 1)
|
48
|
+
when 401
|
49
|
+
logger.trace "IsItDeployed > ERROR: Invalid 'isitdeployed_api_secret'. Check your 'deploy.rb' file"
|
50
|
+
set(:isitdeployed_created, 0)
|
51
|
+
when 404
|
52
|
+
logger.trace "IsItDeployed > ERROR: Invalid 'isitdeployed_project_id'. Check your 'deploy.rb' file"
|
53
|
+
set(:isitdeployed_created, 0)
|
54
|
+
else
|
55
|
+
logger.trace "IsItDeployed > ERROR: Can't create deploy, server returned code #{response.code}"
|
56
|
+
set(:isitdeployed_created, 0)
|
57
|
+
end
|
58
|
+
}
|
82
59
|
end
|
83
60
|
|
84
61
|
namespace :status do
|
@@ -96,17 +73,16 @@ module Capistrano
|
|
96
73
|
desc "Updates deploy status using the API (success or rollback)"
|
97
74
|
task :update do
|
98
75
|
if isitdeployed_created === 1
|
99
|
-
config = Capistrano::Isitdeployed.load_user_config
|
100
76
|
stopped = Capistrano::Isitdeployed.timestamp
|
101
77
|
duration = stopped.to_i - isitdeployed_started.to_i
|
102
|
-
RestClient.put(ENDPOINT + "/p/#{
|
78
|
+
RestClient.put(ENDPOINT + "/p/#{isitdeployed_project_id}/d/#{isitdeployed_did}", JSON.generate({ :status => isitdeployed_status, :stopped => stopped, :duration => duration, :token => isitdeployed_api_secret }), :content_type => :json, :accept => :json, :timeout => 5, :open_timeout => 5){ |response, request, result| response
|
103
79
|
case response.code
|
104
80
|
when 204
|
105
81
|
logger.trace "IsItDeployed > Deploy ##{isitdeployed_did} has been updated for #{application} to #{stage}."
|
106
82
|
when 401
|
107
|
-
logger.trace "IsItDeployed > ERROR: Invalid '
|
83
|
+
logger.trace "IsItDeployed > ERROR: Invalid 'isitdeployed_api_secret'. Check your 'deploy.rb' file"
|
108
84
|
when 404
|
109
|
-
logger.trace "IsItDeployed > ERROR: Invalid '
|
85
|
+
logger.trace "IsItDeployed > ERROR: Invalid 'isitdeployed_project_id'. Check your 'deploy.rb' file"
|
110
86
|
else
|
111
87
|
logger.trace "IsItDeployed > ERROR: Can't create deploy, server returned #{response.code}"
|
112
88
|
end
|