capistrano_scm_nexus 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +26 -0
- data/lib/capistrano/nexus.rb +60 -0
- data/lib/capistrano/tasks/nexus.rake +43 -0
- data/lib/capistrano_scm_nexus.rb +1 -0
- data/lib/capistrano_scm_nexus/version.rb +3 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ad7b7763c7f5a51085f4c56b3f88a262deddde93
|
4
|
+
data.tar.gz: 708d8f116407cc3c312d2f854b12f3e231edb224
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9bd33f6406a05ddf64f0600a827c34dd51db6b0ef0bc75741c915b257841d36a8dda93ec5164aa1b6b58e2e2312c58652c219ec6e7f27d6e823c657a49ab585c
|
7
|
+
data.tar.gz: c68f8e0e1a9d664876ff4bf286ebbd783aa7eb3db54272b44b65e8c069411bdb73ccc5cccab5f3c200d4c8f8a6c25698e0b5cf7e6b86812eeb911baf4207cdb5
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
A gem that enables Capistrano 3 to download artifacts from Artifactory or Nexus
|
2
|
+
and extract their contents to the release directory instead of using SCM to
|
3
|
+
deploy an application.
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
Add `gem 'capistrano_scm_nexus'` to your Gemfile.
|
8
|
+
|
9
|
+
Add `require 'capistrano_scm_nexus'` to your Capfile.
|
10
|
+
|
11
|
+
Set the following configuration variables in `config/deploy.rb` or wherever relevant:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
set :scm, 'nexus'
|
15
|
+
set :nexus_endpoint, 'http://nexus.example.com/nexus/content/repositories'
|
16
|
+
set :nexus_artifact_name, my-application'
|
17
|
+
set :nexus_artifact_version, '1.0.2'
|
18
|
+
set :nexus_repository, 'releases'
|
19
|
+
set :nexus_group_id, 'com.example'
|
20
|
+
```
|
21
|
+
|
22
|
+
Based on the information you provide, the Nexus strategy will download a tgz
|
23
|
+
from the nexus repository and untar and ungzip it into the releases directory.
|
24
|
+
|
25
|
+
This gem expects that you have already tarred and gzipped your application and
|
26
|
+
uploaded it to nexus.
|
@@ -0,0 +1,60 @@
|
|
1
|
+
load File.expand_path('../tasks/nexus.rake', __FILE__)
|
2
|
+
require 'capistrano/scm'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
class Capistrano::Nexus < Capistrano::SCM
|
6
|
+
module DefaultStrategy
|
7
|
+
def artifact_ext
|
8
|
+
'tgz'
|
9
|
+
end
|
10
|
+
|
11
|
+
def artifact_url
|
12
|
+
artifact_name = fetch(:nexus_artifact_name)
|
13
|
+
artifact_version = fetch(:nexus_artifact_version)
|
14
|
+
[ fetch(:nexus_endpoint), fetch(:nexus_repository), *fetch(:nexus_group_id).split('.'),
|
15
|
+
artifact_name, artifact_version, "#{artifact_name}-#{artifact_version}.#{artifact_ext}" ].join('/')
|
16
|
+
end
|
17
|
+
|
18
|
+
def local_filename
|
19
|
+
"#{fetch(:nexus_artifact_version)}.#{artifact_ext}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def test
|
23
|
+
test! " [ -d #{repo_path} ] "
|
24
|
+
end
|
25
|
+
|
26
|
+
def check
|
27
|
+
begin
|
28
|
+
uri = URI(artifact_url)
|
29
|
+
res = Net::HTTP.new(uri.host).request_head(uri.path)
|
30
|
+
if res.code.to_i == 200
|
31
|
+
true
|
32
|
+
else
|
33
|
+
puts "Artifact not found at #{artifact_url}"
|
34
|
+
false
|
35
|
+
end
|
36
|
+
rescue StandardError => e
|
37
|
+
puts "Recieved error: #{e}, backtrace: \n#{e.backtrace}"
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def download
|
43
|
+
context.execute :curl, '-o', local_filename, artifact_url
|
44
|
+
end
|
45
|
+
|
46
|
+
def release
|
47
|
+
context.execute :tar, '-xzf', local_filename, '-C', fetch(:release_path)
|
48
|
+
end
|
49
|
+
|
50
|
+
def cleanup
|
51
|
+
if test! " [ -f #{local_filename} ] "
|
52
|
+
context.execute :rm, local_filename
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def fetch_revision
|
57
|
+
fetch(:nexus_artifact_version)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
namespace :nexus do
|
2
|
+
def strategy
|
3
|
+
@strategy ||= Capistrano::Nexus.new(self, Capistrano::Nexus::DefaultStrategy)
|
4
|
+
end
|
5
|
+
|
6
|
+
desc 'Copy artifact contents to releases'
|
7
|
+
task :create_release do
|
8
|
+
on release_roles :all do
|
9
|
+
within repo_path do
|
10
|
+
strategy.download
|
11
|
+
execute :mkdir, '-p', release_path
|
12
|
+
strategy.release
|
13
|
+
strategy.cleanup
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Check that Nexus is reachable'
|
19
|
+
task :check do
|
20
|
+
exit 1 unless strategy.check
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'Create the repository folder'
|
24
|
+
task :clone do
|
25
|
+
on release_roles :all do
|
26
|
+
if strategy.test
|
27
|
+
info 'Repository folder exists'
|
28
|
+
else
|
29
|
+
info 'Repository folder does not exist: creating #{repo_path}'
|
30
|
+
within deploy_path do
|
31
|
+
execute :mkdir, '-p', repo_path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Determine the revision that will be deployed'
|
38
|
+
task :set_current_revision do
|
39
|
+
on release_roles :all do
|
40
|
+
set :current_revision, strategy.fetch_revision
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path('../capistrano/tasks/nexus.rake', __FILE__)
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano_scm_nexus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jen Page
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-04 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
|
+
description: Enables Capistrano 3 to download artifacts from Nexus and extract their
|
28
|
+
contents to the release directory instead of using SCM to deploy an application
|
29
|
+
email:
|
30
|
+
- jenipage1989@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- README.md
|
36
|
+
- lib/capistrano/nexus.rb
|
37
|
+
- lib/capistrano/tasks/nexus.rake
|
38
|
+
- lib/capistrano_scm_nexus.rb
|
39
|
+
- lib/capistrano_scm_nexus/version.rb
|
40
|
+
homepage: https://github.com/jmpage/capistrano_scm_nexus
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.2.2
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Capistrano SCM Nexus
|
64
|
+
test_files: []
|