capistrano-nexus 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/capistrano-nexus.gemspec +21 -0
- data/lib/capistrano-nexus.rb +130 -0
- data/lib/capistrano-nexus/version.rb +5 -0
- metadata +69 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Yamashita Yuu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# capistrano-nexus
|
2
|
+
|
3
|
+
A Capistrano recipe to deploy [Sonatype Nexus](http://www.sonatype.org/nexus/).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano-nexus'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install capistrano-nexus
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
To deploy Sonatype Nexus, add following in your `config/deploy.rb`.
|
22
|
+
|
23
|
+
# in "config/deploy.rb"
|
24
|
+
require 'capistrano-nexus'
|
25
|
+
|
26
|
+
The following options are available to manage your installation of Sonatype Nexus.
|
27
|
+
|
28
|
+
* `:nexus_version` - The version of Sonatype Nexus.
|
29
|
+
* `:nexus_archive_uri` - The download URL of Sonatype Nexus.
|
30
|
+
* `:nexus_current_path` - The path to the current installation of Sonatype Nexus. Use `:current_path` by default.
|
31
|
+
* `:nexus_release_path` - The path to the new installation of Sonatype Nexus. Use `:release_path` by default.
|
32
|
+
* `:nexus_sonatype_work_path` - The path to the `sonatype-work` directory.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
41
|
+
|
42
|
+
## Author
|
43
|
+
|
44
|
+
- YAMASHITA Yuu (https://github.com/yyuu)
|
45
|
+
- Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
|
46
|
+
|
47
|
+
## License
|
48
|
+
|
49
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano-nexus/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "capistrano-nexus"
|
8
|
+
gem.version = Capistrano::Nexus::VERSION
|
9
|
+
gem.authors = ["Yamashita Yuu"]
|
10
|
+
gem.email = ["yamashita@geishatokyo.com"]
|
11
|
+
gem.description = %q{a capistrano recipe to deploy Sonatype Nexus.}
|
12
|
+
gem.summary = %q{a capistrano recipe to deploy Sonatype Nexus.}
|
13
|
+
gem.homepage = "https://github.com/yyuu/capistrano-nexus"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency('capistrano')
|
21
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require "capistrano-nexus/version"
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Capistrano
|
5
|
+
module SonatypeNexus
|
6
|
+
def self.extended(configuration)
|
7
|
+
configuration.load {
|
8
|
+
namespace(:deploy) {
|
9
|
+
desc("Start Sonatype Nexus.")
|
10
|
+
task(:start, :roles => :app, :except => { :no_release => true }) {
|
11
|
+
find_and_execute_task("nexus:start")
|
12
|
+
}
|
13
|
+
|
14
|
+
desc("Stop Sonatype Nexus.")
|
15
|
+
task(:stop, :roles => :app, :except => { :no_release => true }) {
|
16
|
+
find_and_execute_task("nexus:stop")
|
17
|
+
}
|
18
|
+
|
19
|
+
desc("Restart Sonatype Nexus.")
|
20
|
+
task(:restart, :roles => :app, :except => { :no_release => true }) {
|
21
|
+
find_and_execute_task("nexus:restart")
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
namespace(:nexus) {
|
26
|
+
_cset(:nexus_version, "2.2-01")
|
27
|
+
_cset(:nexus_archive_uri) { "http://www.sonatype.org/downloads/nexus-#{nexus_version}-bundle.tar.gz" }
|
28
|
+
_cset(:nexus_archive_file) { File.join(shared_path, 'tools', 'nexus', File.basename(nexus_archive_uri)) }
|
29
|
+
_cset(:nexus_archive_nexus_path) { File.join(shared_path, 'tools', 'nexus', nexus_version, "nexus-#{nexus_version}") }
|
30
|
+
_cset(:nexus_archive_sonatype_work_path) { File.join(shared_path, 'tools', 'nexus', nexus_version, "sonatype-work") }
|
31
|
+
_cset(:nexus_current_path) { current_path }
|
32
|
+
_cset(:nexus_release_path) { release_path }
|
33
|
+
_cset(:nexus_release_children, %w(bin conf lib nexus))
|
34
|
+
_cset(:nexus_sonatype_work_path) { File.join(shared_path, 'sonatype-work') }
|
35
|
+
|
36
|
+
desc("Setup Sonatype Nexus.")
|
37
|
+
task(:setup, :roles => :app, :except => { :no_release => true }) {
|
38
|
+
transaction {
|
39
|
+
install
|
40
|
+
}
|
41
|
+
}
|
42
|
+
after 'deploy:setup', 'nexus:setup'
|
43
|
+
|
44
|
+
task(:install, :roles => :app, :except => { :no_release => true }) {
|
45
|
+
execute = []
|
46
|
+
dirs = [ File.dirname(nexus_archive_file), File.dirname(nexus_archive_nexus_path) ].uniq
|
47
|
+
execute << "mkdir -p #{dirs.join(' ')}"
|
48
|
+
execute << "( test -f #{nexus_archive_file} || wget --no-verbose -O #{nexus_archive_file} #{nexus_archive_uri} )"
|
49
|
+
execute << "( test -d #{nexus_archive_nexus_path} || tar xf #{nexus_archive_file} -C #{File.dirname(nexus_archive_nexus_path)} )"
|
50
|
+
run(execute.join(' && '))
|
51
|
+
}
|
52
|
+
|
53
|
+
desc("Deploy Sonatype Nexus.")
|
54
|
+
task(:update, :roles => :app, :except => { :no_release => true }) {
|
55
|
+
transaction {
|
56
|
+
install
|
57
|
+
update_nexus
|
58
|
+
update_sonatype_work
|
59
|
+
}
|
60
|
+
}
|
61
|
+
after 'deploy:finalize_update', 'nexus:update'
|
62
|
+
|
63
|
+
task(:update_nexus, :roles => :app, :except => { :no_release => true }) {
|
64
|
+
execute = []
|
65
|
+
dirs = [ File.dirname(nexus_release_path) ]
|
66
|
+
dirs += nexus_release_children.map { |dir| File.join(nexus_release_path, dir) }
|
67
|
+
execute << "mkdir -p #{dirs.join(' ')}"
|
68
|
+
|
69
|
+
nexus_release_children.each do |dir|
|
70
|
+
execute << "rsync -lrpt #{File.join(nexus_archive_nexus_path, dir)}/* #{File.join(nexus_release_path, dir)}"
|
71
|
+
end
|
72
|
+
|
73
|
+
# update log directory
|
74
|
+
execute << "rm -rf #{nexus_release_path}/log #{nexus_release_path}/logs"
|
75
|
+
execute << "ln -sf #{shared_path}/log #{release_path}/logs"
|
76
|
+
|
77
|
+
run(execute.join(' && '))
|
78
|
+
}
|
79
|
+
|
80
|
+
task(:update_sonatype_work, :roles => :app, :except => { :no_release => true }) {
|
81
|
+
execute = []
|
82
|
+
sonatype_work = File.expand_path("#{nexus_release_path}/../sonatype-work")
|
83
|
+
dirs = [ nexus_sonatype_work_path, File.dirname(sonatype_work) ]
|
84
|
+
execute << "mkdir -p #{dirs.join(' ')}"
|
85
|
+
execute << (<<-EOS).gsub(/\s+/, ' ').strip
|
86
|
+
if [ ! -e #{sonatype_work} ] || [ `readlink #{sonatype_work}` != #{nexus_sonatype_work_path} ]; then
|
87
|
+
rm -f #{sonatype_work} && ln -sf #{nexus_sonatype_work_path} #{sonatype_work};
|
88
|
+
fi
|
89
|
+
EOS
|
90
|
+
if fetch(:group_writable, true)
|
91
|
+
execute << "chmod -R g+w #{nexus_release_path}/bin/jsw" # Nexus writes pid file under ${NEXUS_HOME}/bin/jsw
|
92
|
+
execute << "chmod g+w #{nexus_sonatype_work_path}"
|
93
|
+
end
|
94
|
+
run(execute.join(' && '))
|
95
|
+
}
|
96
|
+
|
97
|
+
# original try_runner does not work expectedly with capistrano-2.13.4
|
98
|
+
def _try_runner(cmd, options={})
|
99
|
+
if fetch(:runner, nil)
|
100
|
+
run("#{sudo} -u #{runner} #{cmd}", options)
|
101
|
+
else
|
102
|
+
run(cmd, options)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
desc("Start Sonatype Nexus.")
|
107
|
+
task(:start, :roles => :app, :except => { :no_release => true }) {
|
108
|
+
_try_runner("sh #{nexus_current_path}/bin/nexus start")
|
109
|
+
}
|
110
|
+
|
111
|
+
desc("Stop Sonatype Nexus.")
|
112
|
+
task(:stop, :roles => :app, :except => { :no_release => true }) {
|
113
|
+
_try_runner("sh #{nexus_current_path}/bin/nexus stop")
|
114
|
+
}
|
115
|
+
|
116
|
+
desc("Restart Sonatype Nexus.")
|
117
|
+
task(:restart, :roles => :app, :except => { :no_release => true }) {
|
118
|
+
_try_runner("sh #{nexus_current_path}/bin/nexus restart")
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
if Capistrano::Configuration.instance
|
127
|
+
Capistrano::Configuration.instance.extend(Capistrano::SonatypeNexus)
|
128
|
+
end
|
129
|
+
|
130
|
+
# vim:set ft=ruby ts=2 sw=2 :
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-nexus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yamashita Yuu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: a capistrano recipe to deploy Sonatype Nexus.
|
31
|
+
email:
|
32
|
+
- yamashita@geishatokyo.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- capistrano-nexus.gemspec
|
43
|
+
- lib/capistrano-nexus.rb
|
44
|
+
- lib/capistrano-nexus/version.rb
|
45
|
+
homepage: https://github.com/yyuu/capistrano-nexus
|
46
|
+
licenses: []
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.8.23
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: a capistrano recipe to deploy Sonatype Nexus.
|
69
|
+
test_files: []
|