lita-nexus 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9e8478e68e75511ed9ce99998c40a280a198600
4
- data.tar.gz: 0ab905b4f2370f2c42d54d466bc0d7ed8f8ad4c2
3
+ metadata.gz: cdedb055bad656c003bed738c51b912957953c80
4
+ data.tar.gz: c182af5095912972b6fb58916e67a4ff392512be
5
5
  SHA512:
6
- metadata.gz: 6f1058969a70d8cda6ba1ec122a3b89b9e802442bbadd3741d74f7db602044c359216469241d3fd27bb5e9fccf291d3d91f8bb0ce96cfb8059e72293c52a7f5d
7
- data.tar.gz: 077f3486f956ea6bace8e96408f3b0dbc1949e163e1574ad12752f728565f3071403938c6d9240ac413522b855cbf3b91faedb0b0de3036e38d21e1dad2dde07
6
+ metadata.gz: 339d536f1192d074d4eb4507d56fe006ea3303fe0d031f1cc139a3ad6ffcb7009e223e17e4f98e3ba6f85d55be09efaba8db3c7bd812ed5a3db5e4f4ab3b0722
7
+ data.tar.gz: 58f36b9d550769b5655161f794e5cc3b66a67b064c92ab8b7311cb814f5c0a087cca9a5650b1ca39a307c9dfed885494b08ba6b9c03a115831f7e81bfde79b6e
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # Change Log
2
+ ## 0.1.4
3
+ * Use test artifact in docker container
4
+ * Split search artifact result into multiple messages.
5
+
2
6
  ## 0.1.3
3
7
  * Allow use plain password.
4
8
  * Use docker container for testing.
@@ -1,3 +1,5 @@
1
+ require 'nokogiri'
2
+
1
3
  module Lita
2
4
  module Handlers
3
5
  class Nexus < Handler
@@ -93,7 +95,17 @@ module Lita
93
95
  coordinate = response.matches[0][0]
94
96
  puts "coordinate = #{coordinate}"
95
97
  info = search_for_artifact(coordinate)
96
- response.reply info
98
+ # now parsing xml result
99
+ dom = Nokogiri::XML(info)do |config|
100
+ config.strict.nonet
101
+ end
102
+ total_count = dom.xpath('//totalCount').text
103
+ response.reply "Artifact found: " + total_count
104
+ data = dom.xpath('//artifact')
105
+ data.each do |artifact|
106
+ #response.reply data.to_s.gsub('\\n', '\n')
107
+ response.reply data.to_xml(:indent => 2)
108
+ end
97
109
  end
98
110
 
99
111
  def cmd_license_info(response)
@@ -131,6 +143,9 @@ module Lita
131
143
 
132
144
  end
133
145
 
146
+ def cmd_push_artifact(coordinate, file_path)
147
+ push_artifact(coordinate, file_path)
148
+ end
134
149
  Lita.register_handler(self)
135
150
  end
136
151
  end
@@ -73,5 +73,15 @@ module LitaNexusHelper
73
73
  def get_current_repo
74
74
  config.current_repository || config.default_repository
75
75
  end
76
+
77
+ def push_artifact(coordinate, file_path)
78
+ remote = nexus_remote
79
+ begin
80
+ #boolean result
81
+ success = remote.push_artifact(coordinate, file_path)
82
+ rescue Exception => e
83
+ raise "Failed to push artifact, #{e.message}"
84
+ end
85
+ end
76
86
  end#module Remote
77
87
  end #module helper
data/lita-nexus.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-nexus"
3
- spec.version = "0.1.3"
3
+ spec.version = "0.1.4"
4
4
  spec.authors = ["Wang, Dawei"]
5
5
  spec.email = ["dwang@entertainment.com"]
6
6
  spec.description = "Lita Nexus Operations"
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  #support ruby v 2.1.x
19
19
  spec.add_runtime_dependency "rack", "~> 1.6"
20
20
  spec.add_runtime_dependency "nexus_cli", "~> 4.1"
21
+ spec.add_runtime_dependency "nokogiri"
21
22
 
22
23
  spec.add_development_dependency "bundler", "~> 1.3"
23
24
  #spec.add_development_dependency "pry-byebug"
@@ -2,11 +2,8 @@ require "spec_helper"
2
2
  require 'docker'
3
3
 
4
4
  describe Lita::Handlers::Nexus, lita_handler: true do
5
-
6
5
  before :all do
7
6
  @image = Docker::Image.create('fromImage' => 'sonatype/nexus:oss')
8
-
9
-
10
7
  #
11
8
  @container_data = Docker::Container.create( 'Image' => 'sonatype/nexus:oss',
12
9
  'Cmd' => "true"
@@ -36,6 +33,27 @@ describe Lita::Handlers::Nexus, lita_handler: true do
36
33
  # waiting container to startup
37
34
  wait_time = ENV['LITA_NEXUS_WAIT_TIME'] || 20
38
35
  sleep wait_time
36
+
37
+
38
+
39
+ #now upload test artifact to server
40
+ test_jar = File.expand_path("../../../fixtures/file/maven-reporting-api-2.0.9.jar", __FILE__)
41
+ #puts robot.handlers.to_a[0].class
42
+ overrides = {
43
+ :url => 'http://localhost:8081',
44
+ :repository => 'releases',
45
+ :username => 'admin',
46
+ :password => 'admin123'
47
+ }
48
+ nexus_remote ||= NexusCli::RemoteFactory.create(overrides, false)
49
+
50
+ puts "Upload testing artifact: #{test_jar}"
51
+ success = nexus_remote.push_artifact('org.apache.maven.reporting:maven-reporting:jar:2.0.9', test_jar)
52
+
53
+ unless success
54
+ raise "Failed to upload test artifact"
55
+ end
56
+
39
57
  end
40
58
 
41
59
 
@@ -61,6 +79,7 @@ describe Lita::Handlers::Nexus, lita_handler: true do
61
79
  registry.config.handlers.nexus.verify_ssl = false
62
80
  registry.config.handlers.nexus.default_repository = 'releases'
63
81
  registry.config.handlers.nexus.rsa_private_key = "#{File.expand_path('~')}/.ssh/id_rsa"
82
+
64
83
  end
65
84
  it do
66
85
  is_expected.to route_command('nexus artifact info webapps:sweetrewards:tar.gz:1.8.0').to(:cmd_artifact_info)
@@ -72,15 +91,16 @@ describe Lita::Handlers::Nexus, lita_handler: true do
72
91
  end
73
92
 
74
93
  describe '#get artifact info' do
94
+ #let(:robot) { Lita::Robot.new(registry) }
75
95
  it 'fecth artifact info' do
76
- send_command('nexus artifact info webapps:sweetrewards:tar.gz:1.8.0')
96
+ send_command('nexus artifact info org.apache.maven.reporting:maven-reporting:jar:2.0.9')
77
97
  puts replies
78
98
  end
79
99
  end
80
100
 
81
101
  describe '#search artifact info' do
82
102
  it 'search artifact' do
83
- send_command('nexus search artifact webapps:sweetrewards')
103
+ send_command('nexus search artifact org.apache.maven.reporting:maven-reporting')
84
104
  puts replies
85
105
  end
86
106
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-nexus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wang, Dawei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement