capistrano-deploytags 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +21 -6
- data/lib/capistrano/deploy_tags.rb +15 -3
- metadata +3 -3
data/README.md
CHANGED
@@ -16,7 +16,7 @@ If I were to issue the command:
|
|
16
16
|
This would result in one new git tag with the environment and
|
17
17
|
timestamp:
|
18
18
|
|
19
|
-
`production-2012.04.02-203155`
|
19
|
+
`production-2012.04.02-203155-utc`
|
20
20
|
|
21
21
|
These tags can be used for any number of useful things including
|
22
22
|
generating statistics about deployments per day/week/year, tracking
|
@@ -72,7 +72,7 @@ Disabling Tagging for a Stage
|
|
72
72
|
-----------------------------
|
73
73
|
Sometimes you do not want to enable deployment tagging for a particular
|
74
74
|
stage. In that event, you can simply disable tagging by setting `no_deploytags`
|
75
|
-
|
75
|
+
like so:
|
76
76
|
|
77
77
|
```ruby
|
78
78
|
set :no_deploytags, true
|
@@ -86,6 +86,22 @@ are hooked to the Capistrano Deploytags tasks will also still run, but they may
|
|
86
86
|
find their expectations are not met with regards to the cleanliness of the git
|
87
87
|
tree.
|
88
88
|
|
89
|
+
Customizing the Tag Format
|
90
|
+
--------------------------
|
91
|
+
You may override the time format in `config/deploy.rb`:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
set :deploytag_time_format, "%Y.%m.%d-%H%M%S-utc"
|
95
|
+
```
|
96
|
+
|
97
|
+
Customizing the Tag Commit Message
|
98
|
+
----------------------------------
|
99
|
+
By default, Capistrano Deploytags will create a tag with a message that indicates
|
100
|
+
the local user name on the box where the deployment is done, and the hash of the
|
101
|
+
tagged commit. If you prefer to have a more detailed commit message you may override
|
102
|
+
the `:deploytag_commit_message` setting from your `deploy.rb` or on the command line
|
103
|
+
with `-S deploytag_commit_message='This is my commit message for the deployed tag'`.
|
104
|
+
|
89
105
|
Viewing Deployment History
|
90
106
|
--------------------------
|
91
107
|
It's trivial to view the deployment history for a repo. From a checkout
|
@@ -98,7 +114,6 @@ dev-2013.07.22-114437 gavin deployed 776e15414 to dev
|
|
98
114
|
dev-2013.07.22-115103 karl deployed 619ff5724 to dev
|
99
115
|
dev-2013.07.22-144121 joshmyers deployed cf1ed1a02 to dev
|
100
116
|
```
|
101
|
-
|
102
117
|
A little use of `grep` and you can easily get the history for a
|
103
118
|
particular (e.g. `git tag -l -n1 | grep dev`).
|
104
119
|
|
@@ -128,9 +143,9 @@ supplying `-S branch=<new branch>` as arguments to Capistrano.
|
|
128
143
|
|
129
144
|
Running from Jenkins
|
130
145
|
--------------------
|
131
|
-
Because Jenkins will check out the code with the current revision
|
132
|
-
number you will be in a detached state. This causes the plugin to be
|
133
|
-
unhappy about the git tree. The solution is to add `-S branch=$GIT_COMMIT`
|
146
|
+
Because Jenkins will check out the code with the current revision
|
147
|
+
number you will be in a detached state. This causes the plugin to be
|
148
|
+
unhappy about the git tree. The solution is to add `-S branch=$GIT_COMMIT`
|
134
149
|
to the cap deploy line called from your Jenkins build. This will cause
|
135
150
|
the diffs and comparisons done by the deploytags gem to be correct.
|
136
151
|
|
@@ -9,7 +9,11 @@ module Capistrano
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def git_tag_for(stage)
|
12
|
-
"#{stage}-#{
|
12
|
+
"#{stage}-#{formatted_time}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def formatted_time
|
16
|
+
Time.new.utc.strftime(fetch(:deploytag_time_format, "%Y.%m.%d-%H%M%S-utc"))
|
13
17
|
end
|
14
18
|
|
15
19
|
def safe_run(*args)
|
@@ -39,6 +43,15 @@ module Capistrano
|
|
39
43
|
exists?(:git_remote) ? git_remote : `git remote`.strip.split(/\n/).first
|
40
44
|
end
|
41
45
|
|
46
|
+
def commit_message(current_sha)
|
47
|
+
if exists?(:deploytag_commit_message)
|
48
|
+
deploytag_commit_message
|
49
|
+
else
|
50
|
+
tag_user = (ENV['USER'] || ENV['USERNAME'] || 'deployer').strip
|
51
|
+
"#{tag_user} deployed #{current_sha} to #{stage}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
42
55
|
def self.load_into(configuration)
|
43
56
|
configuration.load do
|
44
57
|
before 'deploy', 'git:prepare_tree'
|
@@ -74,8 +87,7 @@ module Capistrano
|
|
74
87
|
current_sha = `git rev-parse #{branch} HEAD`.strip[0..8]
|
75
88
|
logger.log Capistrano::Logger::INFO, "Tagging #{current_sha} for deployment"
|
76
89
|
|
77
|
-
|
78
|
-
cdt.safe_run 'git', 'tag', '-a', cdt.git_tag_for(stage), '-m', "#{tag_user} deployed #{current_sha} to #{stage}"
|
90
|
+
cdt.safe_run 'git', 'tag', '-a', cdt.git_tag_for(stage), '-m', cdt.commit_message(current_sha)
|
79
91
|
cdt.safe_run 'git', 'push', '--tags' if cdt.has_remote?
|
80
92
|
end
|
81
93
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-deploytags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01
|
12
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -56,8 +56,8 @@ executables: []
|
|
56
56
|
extensions: []
|
57
57
|
extra_rdoc_files: []
|
58
58
|
files:
|
59
|
-
- lib/capistrano/deploy_tags.rb
|
60
59
|
- lib/capistrano-deploytags.rb
|
60
|
+
- lib/capistrano/deploy_tags.rb
|
61
61
|
- README.md
|
62
62
|
- LICENSE
|
63
63
|
homepage: http://github.com/mydrive/capistrano-deploytags
|