module LitaNexusHelper::Remote
Public Instance Methods
delete_artifact(coordinate)
click to toggle source
# File lib/nexushelper/remote.rb, line 73 def delete_artifact(coordinate) remote = nexus_remote remote.delete_artifact(coordinate) end
get_artifact_info(coordinate)
click to toggle source
# File lib/nexushelper/remote.rb, line 29 def get_artifact_info(coordinate) remote = nexus_remote info = nil begin info = remote.get_artifact_info(coordinate) rescue NexusCli::ArtifactNotFoundException => e info = t('msg.info_artifact_not_found') end #puts "info: #{info}" info end
get_current_repo()
click to toggle source
# File lib/nexushelper/remote.rb, line 78 def get_current_repo config.current_repository || config.default_repository end
get_license_info()
click to toggle source
# File lib/nexushelper/remote.rb, line 52 def get_license_info remote = nexus_remote if remote.respond_to? 'get_license_info' remote.get_license_info else #'Only supported on professional version.' t('msg.info_only_supported_on_pro_version') end end
get_repository_info(coordinate)
click to toggle source
# File lib/nexushelper/remote.rb, line 62 def get_repository_info(coordinate) remote = nexus_remote info = nil begin info = remote.get_repository_info(coordinate) rescue NexusCli::RepositoryNotFoundException => e info = t('msg.info_repository_not_found') end info end
nexus_remote()
click to toggle source
# File lib/nexushelper/remote.rb, line 7 def nexus_remote begin if config.password_plain.nil? || config.password_plain.length <1 pk_path = config.rsa_private_key pk = OpenSSL::PKey::RSA.new File.read(pk_path) decrypted_pass = pk.private_decrypt Base64::decode64(config.password_hash) else decrypted_pass = config.password_plain end overrides = { :url => config.url, :repository => get_current_repo, :username => config.username, :password => decrypted_pass } nexus_remote ||= NexusCli::RemoteFactory.create(overrides, config.verify_ssl||false) rescue NexusCli::NexusCliError => e puts e.message end end
push_artifact(coordinate, file_path)
click to toggle source
# File lib/nexushelper/remote.rb, line 82 def push_artifact(coordinate, file_path) remote = nexus_remote begin #boolean result success = remote.push_artifact(coordinate, file_path) rescue Exception => e raise "Failed to push artifact, #{e.message}" end end
search_for_artifact(coordinate)
click to toggle source
# File lib/nexushelper/remote.rb, line 41 def search_for_artifact(coordinate) begin remote = nexus_remote nexus = remote.nexus #puts nexus.inspect info = remote.search_for_artifacts(coordinate) rescue Exception => e raise "Failed to search: #{e.message}" end end
search_with_lucene(coordinate)
click to toggle source
# File lib/nexushelper/remote.rb, line 92 def search_with_lucene(coordinate) remote = nexus_remote nexus = remote.nexus artifact = NexusCli::Artifact.new(coordinate) query = {:g => artifact.group_id, :a => artifact.artifact_id, :e => artifact.extension, :v => artifact.version, :r => get_current_repo} query.merge!({:c => artifact.classifier}) unless artifact.classifier.nil? response = nexus.get(remote.nexus_url("service/local/lucene/search"), query) case response.status when 200 return response.content else raise UnexpectedStatusCodeException.new(response.status) end end