nexus_cli 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/nexus_cli/errors.rb +7 -0
- data/lib/nexus_cli/remote.rb +9 -3
- data/lib/nexus_cli/tasks.rb +12 -6
- metadata +2 -8
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/nexus_cli/errors.rb
CHANGED
@@ -38,4 +38,11 @@ module NexusCli
|
|
38
38
|
end
|
39
39
|
status_code(103)
|
40
40
|
end
|
41
|
+
|
42
|
+
class NonSecureConnectionException < NexusCliError
|
43
|
+
def message
|
44
|
+
"Your communication with a server using an SSL certificate failed during validation. You may want to try the --insecure option."
|
45
|
+
end
|
46
|
+
status_code(104)
|
47
|
+
end
|
41
48
|
end
|
data/lib/nexus_cli/remote.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'restclient'
|
2
2
|
require 'yaml'
|
3
|
+
require 'open3'
|
3
4
|
|
4
5
|
module NexusCli
|
5
6
|
class Remote
|
@@ -43,7 +44,7 @@ module NexusCli
|
|
43
44
|
File.expand_path(artifact.path)
|
44
45
|
end
|
45
46
|
|
46
|
-
def push_artifact(artifact, file)
|
47
|
+
def push_artifact(artifact, file, insecure)
|
47
48
|
#Build up the pieces that will make up the PUT request
|
48
49
|
split_artifact = artifact.split(":")
|
49
50
|
if(split_artifact.size < 4)
|
@@ -55,8 +56,13 @@ module NexusCli
|
|
55
56
|
file_name = "#{split_artifact[1]}-#{version}.#{split_artifact[3]}"
|
56
57
|
|
57
58
|
put_string = "content/repositories/releases/#{artifact_id}/#{group_id}/#{version}/#{file_name}"
|
58
|
-
#
|
59
|
-
|
59
|
+
Open3.popen3("curl #{insecure ? "-k" : ""} -T #{file} #{configuration['url']}#{put_string} -u #{configuration['username']}:#{configuration['password']}") do |stdin, stdout, stderr, wait_thr|
|
60
|
+
exit_code = wait_thr.value.exitstatus
|
61
|
+
case exit_code
|
62
|
+
when 60
|
63
|
+
raise NonSecureConnectionException
|
64
|
+
end
|
65
|
+
end
|
60
66
|
end
|
61
67
|
|
62
68
|
def delete_artifact(artifact)
|
data/lib/nexus_cli/tasks.rb
CHANGED
@@ -11,25 +11,31 @@ module NexusCli
|
|
11
11
|
def pull_artifact(artifact)
|
12
12
|
begin
|
13
13
|
path_to_artifact = Remote.pull_artifact(artifact, options[:destination])
|
14
|
-
|
14
|
+
say "Artifact has been retrived and can be found at path: #{path_to_artifact}", :green
|
15
15
|
rescue NexusCliError => e
|
16
|
-
|
16
|
+
say e.message, :red
|
17
17
|
exit e.status_code
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
desc "push_artifact artifact file", "Pushes an artifact from your machine onto the Nexus."
|
22
|
+
method_options :insecure => false
|
22
23
|
def push_artifact(artifact, file)
|
23
|
-
|
24
|
-
|
24
|
+
begin
|
25
|
+
Remote.push_artifact(artifact, file, options[:insecure])
|
26
|
+
say "Artifact #{artifact} has been successfully pushed to Nexus.", :green
|
27
|
+
rescue NexusCliError => e
|
28
|
+
say e.message, :red
|
29
|
+
exit e.status_code
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
desc "get_artifact_info artifact", "Gets and returns the XML information about a particular artifact."
|
28
34
|
def get_artifact_info(artifact)
|
29
35
|
begin
|
30
|
-
|
36
|
+
say Remote.get_artifact_info(artifact), :green
|
31
37
|
rescue NexusCliError => e
|
32
|
-
|
38
|
+
say e.message, :red
|
33
39
|
exit e.status_code
|
34
40
|
end
|
35
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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: 2012-06-
|
12
|
+
date: 2012-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -147,18 +147,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
147
|
- - ! '>='
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0'
|
150
|
-
segments:
|
151
|
-
- 0
|
152
|
-
hash: 4305968249871314487
|
153
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
151
|
none: false
|
155
152
|
requirements:
|
156
153
|
- - ! '>='
|
157
154
|
- !ruby/object:Gem::Version
|
158
155
|
version: '0'
|
159
|
-
segments:
|
160
|
-
- 0
|
161
|
-
hash: 4305968249871314487
|
162
156
|
requirements: []
|
163
157
|
rubyforge_project:
|
164
158
|
rubygems_version: 1.8.21
|