atlassian_plugin_installer 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2b07b132bbd8fc58db14b6f41eb0b5b766cd1445
4
- data.tar.gz: fda0c0d47c79e8fb799e61f05124eca70356a6f6
2
+ SHA256:
3
+ metadata.gz: d109faf0dc758e5fe873dd6e2bc947973d426ff6412c84900be88be02157e858
4
+ data.tar.gz: e040eea00c1b88c2b707789a8bbbc038675e8fb225f2c713409d32503a0786be
5
5
  SHA512:
6
- metadata.gz: 30c8a4670edab8993e805cd5fd91eaf6d393fe56927ebfb66036bffc13d6f16131922a1fa6563af024c01ee8ce12d9f289ca7cdd00f39f2bf022446da7a0618c
7
- data.tar.gz: f8d1c767b274d573d7b562f44e63d7d582a57882a9c665962ed62b8a9532fb3f95be7d35c853ee5f232c3d5fd45a334a852ffb0bac2558ac5a6b6a9fa63d8de5
6
+ metadata.gz: 979615f7dc64f79046cf3b1a0cad32d8ee21bcc1bbe166aa83fe4ae6f2357c4247ef1e3016fef7c3b11e19d241547ddbed8dae3e786d0f376553dd80aee18665
7
+ data.tar.gz: 1def8502bf080c61c746f48153d9d3fe70179eaae79adbaf17e766a00f8e8d922dccce6573effb033014cf42b6a50619d609db7bd53917c92181b8b92a954f24
@@ -11,6 +11,8 @@ marketplace_username = ARGV[5]
11
11
  marketplace_password = ARGV[6] == "" ? ENV['MARKETPLACE_PASS'] : ARGV[6]
12
12
  license = ARGV[7]
13
13
  application_version = ARGV[8]
14
+ application = ARGV[9] || "jira"
15
+ application_hosting = ARGV[10] || "server"
14
16
 
15
17
  if !(admin_username and admin_password and application_url and plugin_key and (plugin_version or application_version) and marketplace_username and marketplace_password)
16
18
  puts "Usage: atlassian_plugin_installer admin_username admin_password application_url plugin_key plugin_version marketplace_username marketplace_password <license> <application_version>"
@@ -23,7 +25,7 @@ marketplace = AtlassianPluginInstaller::MarketplaceAccessor.new(marketplace_user
23
25
  if (plugin_version and plugin_version != "")
24
26
  plugin_build_number = marketplace.resolve_build_number_from_marketplace(plugin_key, plugin_version)
25
27
  elsif (application_version and application_version != "")
26
- plugin_build_number = marketplace.get_compatible_plugin_build_number_for_atlassian_product_version(plugin_key, application_version, "jira", "server")
28
+ plugin_build_number = marketplace.get_compatible_plugin_build_number_for_atlassian_product_version(plugin_key, application_version, application, application_hosting)
27
29
  else
28
30
  puts "plugin_version or application_version must not be empty"
29
31
  end
@@ -1,3 +1,3 @@
1
1
  module AtlassianPluginInstaller
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -26,16 +26,16 @@ module AtlassianPluginInstaller
26
26
  if plugin_version == "latest"
27
27
  url = "#{MARKETPLACE_ADDONS_URL}/#{plugin_key}/versions/latest"
28
28
  else
29
- url = "#{MARKETPLACE_ADDONS_URL}/#{plugin_key}/versions/name/#{plugin_version}"
29
+ url = "#{MARKETPLACE_ADDONS_URL}/#{plugin_key}/versions/name/#{plugin_version}?limit"
30
30
  end
31
31
  make_get_request(url)
32
32
  end
33
33
 
34
34
  # returns list of versions for plugin
35
- def get_plugin_versions(plugin_key)
35
+ def get_plugin_versions(plugin_key, offset=0)
36
36
  result = []
37
37
  # https://marketplace.atlassian.com/rest/2/addons/com.onresolve.jira.groovy.groovyrunner/versions
38
- url = "#{MARKETPLACE_ADDONS_URL}/#{plugin_key}/versions"
38
+ url = "#{MARKETPLACE_ADDONS_URL}/#{plugin_key}/versions?limit=50&offset=#{offset*50}"
39
39
  response = make_get_request(url)
40
40
  if response['_embedded'] and response['_embedded']['versions']
41
41
  response['_embedded']['versions'].each do |version|
@@ -66,21 +66,26 @@ module AtlassianPluginInstaller
66
66
  def get_compatible_plugin_build_number_for_atlassian_product_version(plugin_key, product_version, product_name="jira", product_hosting="server")
67
67
  puts "Seraching for compatible plugin version for plugin #{plugin_key} and product version #{product_version}"
68
68
  required_version = Gem::Version.new(product_version)
69
- get_plugin_versions(plugin_key).each do |version|
70
- puts "Inspecting #{plugin_key} version #{version}"
71
- version_details = get_plugin_details_for_version(plugin_key, version)
72
- compatibilities = version_details['compatibilities']
73
- if compatibilities
74
- compatibilities.each do |comp|
75
- if ( comp['application'] and comp['application'] == product_name and comp['hosting'] and comp['hosting'][product_hosting])
76
- compatibility_with = comp['hosting'][product_hosting]
77
- min_version = compatibility_with["min"]["version"]
78
- max_version = compatibility_with["max"]["version"]
79
- if (Gem::Version.new(max_version) >= required_version and
80
- Gem::Version.new(min_version) <= required_version)
81
- # add condition and dont break if searching for the highest
82
- # if found return the buildNumber
83
- return version_details['buildNumber']
69
+ # test max last 500 versions
70
+ (0..10).each do |offset|
71
+ get_plugin_versions(plugin_key, offset).each do |version|
72
+ puts "Inspecting #{plugin_key} version #{version}"
73
+ version_details = get_plugin_details_for_version(plugin_key, version)
74
+ compatibilities = version_details['compatibilities']
75
+ puts "Version details:" + compatibilities.inspect
76
+ if compatibilities
77
+ compatibilities.each do |comp|
78
+ puts "Comp: "+ comp.inspect
79
+ if ( comp['application'] and comp['application'] == product_name and comp['hosting'] and comp['hosting'][product_hosting])
80
+ compatibility_with = comp['hosting'][product_hosting]
81
+ min_version = compatibility_with["min"]["version"]
82
+ max_version = compatibility_with["max"]["version"]
83
+ if (Gem::Version.new(max_version) >= required_version and
84
+ Gem::Version.new(min_version) <= required_version)
85
+ # add condition and dont break if searching for the highest
86
+ # if found return the buildNumber
87
+ return version_details['buildNumber']
88
+ end
84
89
  end
85
90
  end
86
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlassian_plugin_installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Brehovsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-10 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.4.5
79
+ rubygems_version: 2.7.1
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Installs JIRA plugin using UPM