lib/nexus_cli/remote.rb in nexus_cli-0.0.4 vs lib/nexus_cli/remote.rb in nexus_cli-0.0.5
- old
+ new
@@ -1,7 +1,8 @@
require 'restclient'
require 'yaml'
+require 'open3'
module NexusCli
class Remote
class << self
@@ -41,11 +42,11 @@
artifact.write(fileData)
artifact.close()
File.expand_path(artifact.path)
end
- def push_artifact(artifact, file)
+ def push_artifact(artifact, file, insecure)
#Build up the pieces that will make up the PUT request
split_artifact = artifact.split(":")
if(split_artifact.size < 4)
raise ArtifactMalformedException
end
@@ -53,11 +54,16 @@
group_id = split_artifact[1].gsub(".", "/")
version = split_artifact[2]
file_name = "#{split_artifact[1]}-#{version}.#{split_artifact[3]}"
put_string = "content/repositories/releases/#{artifact_id}/#{group_id}/#{version}/#{file_name}"
- #nexus[put_string].put File.read(file), :accept => "*/*"
- Kernel.quietly {`curl -T #{file} #{configuration['url']}#{put_string} -u #{configuration['username']}:#{configuration['password']}`}
+ Open3.popen3("curl #{insecure ? "-k" : ""} -T #{file} #{configuration['url']}#{put_string} -u #{configuration['username']}:#{configuration['password']}") do |stdin, stdout, stderr, wait_thr|
+ exit_code = wait_thr.value.exitstatus
+ case exit_code
+ when 60
+ raise NonSecureConnectionException
+ end
+ end
end
def delete_artifact(artifact)
split_artifact = artifact.split(":")
if(split_artifact.size < 4)
\ No newline at end of file