fastlane-plugin-airwatch_workspaceone 2.3.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/add_or_update_assignments_action.rb +5 -27
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/delete_previous_versions_action.rb +18 -53
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/delete_specific_version_action.rb +14 -61
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/deploy_build_action.rb +44 -4
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/latest_version_action.rb +182 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/retire_previous_versions_action.rb +13 -68
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/retire_specific_version_action.rb +13 -67
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_all_versions.rb +13 -67
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb +13 -67
- data/lib/fastlane/plugin/airwatch_workspaceone/helper/airwatch_workspaceone_helper.rb +130 -1
- data/lib/fastlane/plugin/airwatch_workspaceone/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23a24e8e7abab45317fbb762787db007bc81cc11c36bda46c5b17b26cd949b56
|
4
|
+
data.tar.gz: 002cc296d31c9bdc141b8325ab887761294142dcef9d61ccf9286faa43bf1ff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d42673b8e6596baf6ac3ee2830bb63078a345d9789690bb9c4b15721ebf08567004b4f8c322139d7039bd64f396318d702e91e80cde84ea6187855f990f189a
|
7
|
+
data.tar.gz: dcd4263e484eccbd0aeed3dbee8cac11ff8429b2b6abbd535e246ffa580a5da817bad3ed904ae69b1a5cc215f3854e5397643bacbf4c85c6bb89869e7e901792
|
@@ -5,7 +5,6 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class AddOrUpdateAssignmentsAction < Action
|
7
7
|
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
|
9
8
|
ADD_UPDATE_ASSIGNMENT_SUFFIX = "/API/mam/apps/internal/%d/assignments"
|
10
9
|
SEARCH_SMART_GROUP_SUFFIX = "/API/mdm/smartgroups/search?name=%s&organizationgroupid=%d"
|
11
10
|
|
@@ -103,8 +102,8 @@ module Fastlane
|
|
103
102
|
|
104
103
|
def self.find_app_smart_groups(app_identifier)
|
105
104
|
# get the list of apps
|
106
|
-
|
107
|
-
app_versions =
|
105
|
+
apps = Helper::AirwatchWorkspaceoneHelper.list_app_versions(app_identifier, $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
106
|
+
app_versions = apps['Application']
|
108
107
|
|
109
108
|
if app_versions.count <= 0
|
110
109
|
UI.user_error!("No app found on the console having bundle identifier: %s" % [app_identifier])
|
@@ -119,35 +118,14 @@ module Fastlane
|
|
119
118
|
return app_smart_groups
|
120
119
|
end
|
121
120
|
|
122
|
-
def self.list_app_versions(app_identifier)
|
123
|
-
require 'rest-client'
|
124
|
-
require 'json'
|
125
|
-
|
126
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
127
|
-
|
128
|
-
if debug
|
129
|
-
UI.message("Response code: %d" % [response.code])
|
130
|
-
UI.message("Response body:")
|
131
|
-
UI.message(response.body)
|
132
|
-
end
|
133
|
-
|
134
|
-
if response.code != 200
|
135
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
136
|
-
exit
|
137
|
-
end
|
138
|
-
|
139
|
-
json = JSON.parse(response.body)
|
140
|
-
return json
|
141
|
-
end
|
142
|
-
|
143
121
|
def self.find_smart_group_id(smart_group_name)
|
144
|
-
|
122
|
+
smart_groups = fetch_smart_group_details(smart_group_name)
|
145
123
|
smart_group_id = -1
|
146
|
-
if
|
124
|
+
if smart_groups.empty?
|
147
125
|
return smart_group_id
|
148
126
|
end
|
149
127
|
|
150
|
-
|
128
|
+
smart_groups['SmartGroups'].each do |smart_group|
|
151
129
|
smart_group_id = smart_group['SmartGroupID']
|
152
130
|
end
|
153
131
|
|
@@ -5,9 +5,6 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class DeletePreviousVersionsAction < Action
|
7
7
|
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
|
9
|
-
INTERNAL_APP_DELETE_SUFFIX = "/API/mam/apps/internal/%d"
|
10
|
-
|
11
8
|
$is_debug = false
|
12
9
|
|
13
10
|
def self.run(params)
|
@@ -23,6 +20,7 @@ module Fastlane
|
|
23
20
|
UI.message(" host_url: #{params[:host_url]}")
|
24
21
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
25
22
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
23
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
26
24
|
UI.message(" app_identifier: #{params[:app_identifier]}")
|
27
25
|
UI.message(" keep_latest_versions_count: #{params[:keep_latest_versions_count]}")
|
28
26
|
end
|
@@ -30,6 +28,7 @@ module Fastlane
|
|
30
28
|
$host_url = params[:host_url]
|
31
29
|
$aw_tenant_code = params[:aw_tenant_code]
|
32
30
|
$b64_encoded_auth = params[:b64_encoded_auth]
|
31
|
+
$org_group_id = params[:org_group_id]
|
33
32
|
app_identifier = params[:app_identifier]
|
34
33
|
keep_latest_versions_count = params[:keep_latest_versions_count]
|
35
34
|
|
@@ -38,7 +37,7 @@ module Fastlane
|
|
38
37
|
UI.message("1. Finding app versions")
|
39
38
|
UI.message("-----------------------")
|
40
39
|
|
41
|
-
app_versions =
|
40
|
+
app_versions = find_app_versions(app_identifier)
|
42
41
|
UI.success("Found %d app version(s)" % [app_versions.count])
|
43
42
|
UI.success("Version number(s): %s" % [app_versions.map {|app_version| app_version.values[1]}])
|
44
43
|
|
@@ -55,29 +54,25 @@ module Fastlane
|
|
55
54
|
app_versions.pop(keep_latest_versions_count_int)
|
56
55
|
UI.important("Version number(s) to delete: %s" % [app_versions.map {|app_version| app_version.values[1]}])
|
57
56
|
app_versions.each do |app_version|
|
58
|
-
delete_app(app_version)
|
57
|
+
Helper::AirwatchWorkspaceoneHelper.delete_app(app_version, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
|
59
58
|
end
|
60
59
|
UI.success("Version(s) %s successfully deleted." % [app_versions.map {|app_version| app_version.values[1]}])
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
64
|
-
def self.
|
63
|
+
def self.find_app_versions(app_identifier)
|
65
64
|
# get the list of apps
|
66
|
-
|
65
|
+
apps = Helper::AirwatchWorkspaceoneHelper.list_app_versions(app_identifier, $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
67
66
|
app_versions = Array.new
|
68
67
|
active_app_versions = Array.new
|
69
68
|
retired_app_versions = Array.new
|
70
69
|
|
71
|
-
|
70
|
+
apps['Application'].each do |app|
|
72
71
|
if app['Status'] == "Active"
|
73
|
-
active_app_version =
|
74
|
-
active_app_version['Id'] = app['Id']['Value']
|
75
|
-
active_app_version['Version'] = app['AppVersion']
|
72
|
+
active_app_version = Helper::AirwatchWorkspaceoneHelper.construct_app_version(app)
|
76
73
|
active_app_versions << active_app_version
|
77
74
|
elsif app["Status"] == "Retired"
|
78
|
-
retired_app_version =
|
79
|
-
retired_app_version['Id'] = app['Id']['Value']
|
80
|
-
retired_app_version['Version'] = app['AppVersion']
|
75
|
+
retired_app_version = Helper::AirwatchWorkspaceoneHelper.construct_app_version(app)
|
81
76
|
retired_app_versions << retired_app_version
|
82
77
|
end
|
83
78
|
end
|
@@ -89,45 +84,6 @@ module Fastlane
|
|
89
84
|
return app_versions
|
90
85
|
end
|
91
86
|
|
92
|
-
def self.list_app_versions(app_identifier)
|
93
|
-
require 'rest-client'
|
94
|
-
require 'json'
|
95
|
-
|
96
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
97
|
-
|
98
|
-
if debug
|
99
|
-
UI.message("Response code: %d" % [response.code])
|
100
|
-
UI.message("Response body:")
|
101
|
-
UI.message(response.body)
|
102
|
-
end
|
103
|
-
|
104
|
-
if response.code != 200
|
105
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
106
|
-
exit
|
107
|
-
end
|
108
|
-
|
109
|
-
json = JSON.parse(response.body)
|
110
|
-
return json
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.delete_app(app_version)
|
114
|
-
require 'rest-client'
|
115
|
-
require 'json'
|
116
|
-
|
117
|
-
UI.message("Starting to delete app version: %s" % [app_version['Version']])
|
118
|
-
response = RestClient.delete($host_url + INTERNAL_APP_DELETE_SUFFIX % [app_version['Id']], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
119
|
-
|
120
|
-
if debug
|
121
|
-
UI.message("Response code: %d" % [response.code])
|
122
|
-
end
|
123
|
-
|
124
|
-
if response.code == 204
|
125
|
-
UI.message("Successfully deleted app version: %s" % [app_version['Version']])
|
126
|
-
else
|
127
|
-
UI.message("Failed to delete app version: %s" % [app_version['Version']])
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
87
|
def self.description
|
132
88
|
"The main purpose of this action is to delete versions of an application. This action takes a string parameter where you can specify the number of latest versions to keep if you do not want to delete all the versions."
|
133
89
|
end
|
@@ -174,6 +130,15 @@ module Fastlane
|
|
174
130
|
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
175
131
|
end),
|
176
132
|
|
133
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
134
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
135
|
+
description: "Organization Group ID integer identifying the customer or container",
|
136
|
+
optional: false,
|
137
|
+
type: String,
|
138
|
+
verify_block: proc do |value|
|
139
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
140
|
+
end),
|
141
|
+
|
177
142
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
178
143
|
env_name: "APP_IDENTIFIER",
|
179
144
|
description: "Bundle identifier of your app",
|
@@ -3,10 +3,7 @@ require_relative '../helper/airwatch_workspaceone_helper'
|
|
3
3
|
|
4
4
|
module Fastlane
|
5
5
|
module Actions
|
6
|
-
class DeleteSpecificVersionAction < Action
|
7
|
-
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
|
9
|
-
INTERNAL_APP_DELETE_SUFFIX = "/API/mam/apps/internal/%d"
|
6
|
+
class DeleteSpecificVersionAction < Action
|
10
7
|
|
11
8
|
$is_debug = false
|
12
9
|
|
@@ -23,6 +20,7 @@ module Fastlane
|
|
23
20
|
UI.message(" host_url: #{params[:host_url]}")
|
24
21
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
25
22
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
23
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
26
24
|
UI.message(" app_identifier: #{params[:app_identifier]}")
|
27
25
|
UI.message(" version_number: #{params[:version_number]}")
|
28
26
|
end
|
@@ -30,6 +28,7 @@ module Fastlane
|
|
30
28
|
$host_url = params[:host_url]
|
31
29
|
$aw_tenant_code = params[:aw_tenant_code]
|
32
30
|
$b64_encoded_auth = params[:b64_encoded_auth]
|
31
|
+
$org_group_id = params[:org_group_id]
|
33
32
|
app_identifier = params[:app_identifier]
|
34
33
|
version_number = params[:version_number]
|
35
34
|
|
@@ -38,7 +37,7 @@ module Fastlane
|
|
38
37
|
UI.message("1. Finding app versions")
|
39
38
|
UI.message("-----------------------")
|
40
39
|
|
41
|
-
app_versions =
|
40
|
+
app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'None', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
42
41
|
app_version_numbers = app_versions.map {|app_version| app_version.values[1]}
|
43
42
|
UI.success("Found %d app version(s)" % [app_versions.count])
|
44
43
|
UI.success("Version number(s): %s" % [app_version_numbers])
|
@@ -51,7 +50,7 @@ module Fastlane
|
|
51
50
|
if app_version_numbers.include? version_number
|
52
51
|
version_index = app_version_numbers.index(version_number)
|
53
52
|
app_version_to_delete = app_versions[version_index]
|
54
|
-
delete_app(app_version_to_delete)
|
53
|
+
Helper::AirwatchWorkspaceoneHelper.delete_app(app_version_to_delete, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
|
55
54
|
else
|
56
55
|
UI.user_error!("A version with the given version number: %s does not exist on the console for this application or is already deleted." % [version_number])
|
57
56
|
end
|
@@ -59,61 +58,6 @@ module Fastlane
|
|
59
58
|
UI.success("Version %s successfully deleted" % [version_number])
|
60
59
|
end
|
61
60
|
|
62
|
-
def self.find_app(app_identifier)
|
63
|
-
# get the list of apps
|
64
|
-
data = list_app_versions(app_identifier)
|
65
|
-
app_versions = Array.new
|
66
|
-
|
67
|
-
data['Application'].each do |app|
|
68
|
-
app_version = Hash.new
|
69
|
-
app_version['Id'] = app['Id']['Value']
|
70
|
-
app_version['Version'] = app['AppVersion']
|
71
|
-
app_versions << app_version
|
72
|
-
end
|
73
|
-
|
74
|
-
app_versions.sort_by! { |app_version| app_version["Id"] }
|
75
|
-
return app_versions
|
76
|
-
end
|
77
|
-
|
78
|
-
def self.list_app_versions(app_identifier)
|
79
|
-
require 'rest-client'
|
80
|
-
require 'json'
|
81
|
-
|
82
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
83
|
-
|
84
|
-
if debug
|
85
|
-
UI.message("Response code: %d" % [response.code])
|
86
|
-
UI.message("Response body:")
|
87
|
-
UI.message(response.body)
|
88
|
-
end
|
89
|
-
|
90
|
-
if response.code != 200
|
91
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
92
|
-
exit
|
93
|
-
end
|
94
|
-
|
95
|
-
json = JSON.parse(response.body)
|
96
|
-
return json
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.delete_app(app_version)
|
100
|
-
require 'rest-client'
|
101
|
-
require 'json'
|
102
|
-
|
103
|
-
UI.message("Starting to delete app version: %s" % [app_version['Version']])
|
104
|
-
response = RestClient.delete($host_url + INTERNAL_APP_DELETE_SUFFIX % [app_version['Id']], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
105
|
-
|
106
|
-
if debug
|
107
|
-
UI.message("Response code: %d" % [response.code])
|
108
|
-
end
|
109
|
-
|
110
|
-
if response.code == 204
|
111
|
-
UI.message("Successfully deleted app version: %s" % [app_version['Version']])
|
112
|
-
else
|
113
|
-
UI.message("Failed to delete app version: %s" % [app_version['Version']])
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
61
|
def self.description
|
118
62
|
"The main purpose of this action is to delete a specific version of an application. This action takes a string parameter where you can specify the version number to delete."
|
119
63
|
end
|
@@ -160,6 +104,15 @@ module Fastlane
|
|
160
104
|
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
161
105
|
end),
|
162
106
|
|
107
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
108
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
109
|
+
description: "Organization Group ID integer identifying the customer or container",
|
110
|
+
optional: false,
|
111
|
+
type: String,
|
112
|
+
verify_block: proc do |value|
|
113
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
114
|
+
end),
|
115
|
+
|
163
116
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
164
117
|
env_name: "APP_IDENTIFIER",
|
165
118
|
description: "Bundle identifier of your app",
|
@@ -3,10 +3,15 @@ require_relative '../helper/airwatch_workspaceone_helper'
|
|
3
3
|
|
4
4
|
module Fastlane
|
5
5
|
module Actions
|
6
|
+
module SharedValues
|
7
|
+
DEPLOYED_APP_UUID ||= :SIGH_PROFILE_PATH
|
8
|
+
end
|
9
|
+
|
6
10
|
class DeployBuildAction < Action
|
7
11
|
|
8
12
|
UPLOAD_BLOB_SUFFIX = "/API/mam/blobs/uploadblob?fileName=%s&organizationGroupId=%s"
|
9
13
|
BEGIN_INSTALL_SUFFIX = "/API/mam/apps/internal/begininstall"
|
14
|
+
DELETE_BLOB_SUFFIX = "/API/mam/blobs/blob/%d"
|
10
15
|
|
11
16
|
$is_debug = false
|
12
17
|
$device_type = "Apple"
|
@@ -128,7 +133,6 @@ module Fastlane
|
|
128
133
|
end
|
129
134
|
|
130
135
|
def self.create_model_for(model_id, model_name)
|
131
|
-
|
132
136
|
model_hash = Hash.new
|
133
137
|
model_hash['ModelId'] = model_id
|
134
138
|
model_hash['ModelName'] = model_name
|
@@ -184,9 +188,10 @@ module Fastlane
|
|
184
188
|
begin
|
185
189
|
response = RestClient.post($host_url + BEGIN_INSTALL_SUFFIX, body.to_json, {content_type: :json, accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
186
190
|
rescue RestClient::ExceptionWithResponse => e
|
187
|
-
UI.
|
188
|
-
UI.
|
189
|
-
UI.
|
191
|
+
UI.error("ERROR! Response code: %d" % [e.response.code])
|
192
|
+
UI.error("Response body:")
|
193
|
+
UI.error(e.response.body)
|
194
|
+
delete_blob(blobID)
|
190
195
|
raise
|
191
196
|
end
|
192
197
|
|
@@ -197,9 +202,38 @@ module Fastlane
|
|
197
202
|
end
|
198
203
|
|
199
204
|
json = JSON.parse(response.body)
|
205
|
+
Actions.lane_context[SharedValues::DEPLOYED_APP_UUID] = json['Uuid']
|
200
206
|
return json
|
201
207
|
end
|
202
208
|
|
209
|
+
def self.delete_blob(blobID)
|
210
|
+
require 'rest-client'
|
211
|
+
require 'json'
|
212
|
+
|
213
|
+
if debug
|
214
|
+
UI.message("Deleting Blob with ID: %d" % [blobID])
|
215
|
+
end
|
216
|
+
|
217
|
+
begin
|
218
|
+
response = RestClient.delete($host_url + DELETE_BLOB_SUFFIX % [blobID], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
219
|
+
rescue RestClient::ExceptionWithResponse => e
|
220
|
+
UI.error("ERROR! Response code: %d" % [e.response.code])
|
221
|
+
UI.error("Response body:")
|
222
|
+
UI.error(e.response.body)
|
223
|
+
raise
|
224
|
+
end
|
225
|
+
|
226
|
+
if debug
|
227
|
+
UI.message("Response code: %d" % [response.code])
|
228
|
+
end
|
229
|
+
|
230
|
+
if response.code == 200
|
231
|
+
UI.message("Successfully deleted blob")
|
232
|
+
else
|
233
|
+
UI.message("Failed to delete blob")
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
203
237
|
def self.description
|
204
238
|
"The main purpose of this action is to upload an IPA or an APK file to an AirWatch or Workspace ONE enterprise console."
|
205
239
|
end
|
@@ -208,6 +242,12 @@ module Fastlane
|
|
208
242
|
["Ram Awadhesh Sharan"]
|
209
243
|
end
|
210
244
|
|
245
|
+
def self.output
|
246
|
+
[
|
247
|
+
['DEPLOYED_APP_UUID', 'The unique identifier of the deployed application in uuid format']
|
248
|
+
]
|
249
|
+
end
|
250
|
+
|
211
251
|
def self.return_value
|
212
252
|
# If your method provides a return value, you can describe here what it does
|
213
253
|
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/airwatch_workspaceone_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
LATEST_VERSION_NUMBER ||= :LATEST_VERSION_NUMBER
|
8
|
+
ACTIVE_VERSION_NUMBERS ||= :ACTIVE_VERSION_NUMBERS
|
9
|
+
RETIRED_VERSION_NUMEBRS ||= :RETIRED_VERSION_NUMEBRS
|
10
|
+
end
|
11
|
+
|
12
|
+
class LatestVersionAction < Action
|
13
|
+
|
14
|
+
$is_debug = false
|
15
|
+
|
16
|
+
def self.run(params)
|
17
|
+
UI.message("The airwatch_workspaceone plugin is working!")
|
18
|
+
|
19
|
+
# check if debug is enabled
|
20
|
+
$is_debug = params[:debug]
|
21
|
+
|
22
|
+
if debug
|
23
|
+
UI.message("-------------------------------------")
|
24
|
+
UI.message("LatestVersionAction debug information")
|
25
|
+
UI.message("-------------------------------------")
|
26
|
+
UI.message(" host_url: #{params[:host_url]}")
|
27
|
+
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
28
|
+
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
29
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
30
|
+
UI.message(" app_identifier: #{params[:app_identifier]}")
|
31
|
+
end
|
32
|
+
|
33
|
+
$host_url = params[:host_url]
|
34
|
+
$aw_tenant_code = params[:aw_tenant_code]
|
35
|
+
$b64_encoded_auth = params[:b64_encoded_auth]
|
36
|
+
$org_group_id = params[:org_group_id]
|
37
|
+
app_identifier = params[:app_identifier]
|
38
|
+
|
39
|
+
# step 1: find app
|
40
|
+
UI.message("-----------------------")
|
41
|
+
UI.message("1. Finding app versions")
|
42
|
+
UI.message("-----------------------")
|
43
|
+
|
44
|
+
app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'None', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
45
|
+
app_version_numbers = app_versions.map {|app_version| app_version.values[1]}
|
46
|
+
UI.success("Found %d app version(s)" % [app_versions.count])
|
47
|
+
UI.success("Version number(s): %s" % [app_version_numbers])
|
48
|
+
UI.success("Latest version: %s" % [app_version_numbers.last])
|
49
|
+
|
50
|
+
# step 2: find active versions of app
|
51
|
+
if debug
|
52
|
+
UI.message("------------------------------")
|
53
|
+
UI.message("2. Finding Active app versions")
|
54
|
+
UI.message("------------------------------")
|
55
|
+
end
|
56
|
+
|
57
|
+
active_app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'Active', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
58
|
+
active_app_version_numbers = active_app_versions.map {|active_app_version| active_app_version.values[1]}
|
59
|
+
Actions.lane_context[SharedValues::ACTIVE_VERSION_NUMBERS] = active_app_version_numbers
|
60
|
+
|
61
|
+
if debug
|
62
|
+
UI.success("Found %d Active app version(s)" % [active_app_versions.count])
|
63
|
+
UI.success("Active app Version number(s): %s" % [active_app_version_numbers])
|
64
|
+
end
|
65
|
+
|
66
|
+
# step 3: find retired versions of app
|
67
|
+
if debug
|
68
|
+
UI.message("-------------------------------")
|
69
|
+
UI.message("2. Finding Retired app versions")
|
70
|
+
UI.message("-------------------------------")
|
71
|
+
end
|
72
|
+
|
73
|
+
retired_app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'Retired', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
74
|
+
retired_app_version_numbers = retired_app_versions.map {|retired_app_version| retired_app_version.values[1]}
|
75
|
+
Actions.lane_context[SharedValues::RETIRED_VERSION_NUMEBRS] = retired_app_version_numbers
|
76
|
+
|
77
|
+
if debug
|
78
|
+
UI.success("Found %d Retired app version(s)" % [retired_app_versions.count])
|
79
|
+
UI.success("Retired app Version number(s): %s" % [retired_app_version_numbers])
|
80
|
+
end
|
81
|
+
|
82
|
+
return Actions.lane_context[SharedValues::LATEST_VERSION_NUMBER] = app_version_numbers.last
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.description
|
86
|
+
"The main purpose of this action is to find the version number of the latest version of the app on the console and output the same. It also finds and outputs arrays of active app version numbers and retired app version numbers of the app."
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.authors
|
90
|
+
["Ram Awadhesh Sharan"]
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.output
|
94
|
+
[
|
95
|
+
['LATEST_VERSION_NUMBER', 'Version number of the latest version of app on the console'],
|
96
|
+
['ACTIVE_VERSION_NUMBERS', 'An array of version numbers of active versions of the app on the console'],
|
97
|
+
['RETIRED_VERSION_NUMEBRS', 'An array of version numbers of retired versions of the app on the console']
|
98
|
+
]
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.return_value
|
102
|
+
"Version number of the latest version of app on the console"
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.details
|
106
|
+
# Optional:
|
107
|
+
"latest_version - To find the version number of the latest version of the app on the Workspace One console."
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.available_options
|
111
|
+
[
|
112
|
+
FastlaneCore::ConfigItem.new(key: :host_url,
|
113
|
+
env_name: "AIRWATCH_HOST_API_URL",
|
114
|
+
description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
|
115
|
+
optional: false,
|
116
|
+
type: String,
|
117
|
+
verify_block: proc do |value|
|
118
|
+
UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
|
119
|
+
end),
|
120
|
+
|
121
|
+
FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
|
122
|
+
env_name: "AIRWATCH_API_KEY",
|
123
|
+
description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
|
124
|
+
optional: false,
|
125
|
+
type: String,
|
126
|
+
verify_block: proc do |value|
|
127
|
+
UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
|
128
|
+
end),
|
129
|
+
|
130
|
+
FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
|
131
|
+
env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
|
132
|
+
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch/Workspace ONE instance",
|
133
|
+
optional: false,
|
134
|
+
type: String,
|
135
|
+
verify_block: proc do |value|
|
136
|
+
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
137
|
+
end),
|
138
|
+
|
139
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
140
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
141
|
+
description: "Organization Group ID integer identifying the customer or container",
|
142
|
+
optional: false,
|
143
|
+
type: String,
|
144
|
+
verify_block: proc do |value|
|
145
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
146
|
+
end),
|
147
|
+
|
148
|
+
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
149
|
+
env_name: "APP_IDENTIFIER",
|
150
|
+
description: "Bundle identifier of your app",
|
151
|
+
optional: false,
|
152
|
+
type: String,
|
153
|
+
verify_block: proc do |value|
|
154
|
+
UI.user_error!("No app identifier given, pass using `app_identifier: 'com.example.app'`") unless value and !value.empty?
|
155
|
+
end),
|
156
|
+
|
157
|
+
FastlaneCore::ConfigItem.new(key: :debug,
|
158
|
+
env_name: "AIRWATCH_DEBUG",
|
159
|
+
description: "Debug flag, set to true to show extended output. default: false",
|
160
|
+
optional: true,
|
161
|
+
is_string: false,
|
162
|
+
default_value: false)
|
163
|
+
]
|
164
|
+
end
|
165
|
+
|
166
|
+
def self.is_supported?(platform)
|
167
|
+
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
168
|
+
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
169
|
+
|
170
|
+
[:ios, :android].include?(platform)
|
171
|
+
true
|
172
|
+
end
|
173
|
+
|
174
|
+
# helpers
|
175
|
+
|
176
|
+
def self.debug
|
177
|
+
$is_debug
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -5,9 +5,6 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class RetirePreviousVersionsAction < Action
|
7
7
|
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
|
9
|
-
INTERNAL_APP_RETIRE_SUFFIX = "/API/mam/apps/internal/%d/retire"
|
10
|
-
|
11
8
|
$is_debug = false
|
12
9
|
|
13
10
|
def self.run(params)
|
@@ -23,6 +20,7 @@ module Fastlane
|
|
23
20
|
UI.message(" host_url: #{params[:host_url]}")
|
24
21
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
25
22
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
23
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
26
24
|
UI.message(" app_identifier: #{params[:app_identifier]}")
|
27
25
|
UI.message(" keep_latest_versions_count: #{params[:keep_latest_versions_count]}")
|
28
26
|
end
|
@@ -30,16 +28,16 @@ module Fastlane
|
|
30
28
|
$host_url = params[:host_url]
|
31
29
|
$aw_tenant_code = params[:aw_tenant_code]
|
32
30
|
$b64_encoded_auth = params[:b64_encoded_auth]
|
31
|
+
$org_group_id = params[:org_group_id]
|
33
32
|
app_identifier = params[:app_identifier]
|
34
33
|
keep_latest_versions_count = params[:keep_latest_versions_count]
|
35
|
-
UI.message(APP_VERSIONS_LIST_SUFFIX % [app_identifier])
|
36
34
|
|
37
35
|
# step 1: find app
|
38
36
|
UI.message("------------------------------")
|
39
37
|
UI.message("1. Finding active app versions")
|
40
38
|
UI.message("------------------------------")
|
41
39
|
|
42
|
-
app_versions =
|
40
|
+
app_versions = app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'Active', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
43
41
|
UI.success("Found %d active app version(s)" % [app_versions.count])
|
44
42
|
UI.success("Version number(s): %s" % [app_versions.map {|app_version| app_version.values[1]}])
|
45
43
|
|
@@ -56,74 +54,12 @@ module Fastlane
|
|
56
54
|
app_versions.pop(keep_latest_versions_count_int)
|
57
55
|
UI.important("Version number(s) to retire: %s" % [app_versions.map {|app_version| app_version.values[1]}])
|
58
56
|
app_versions.each do |app_version|
|
59
|
-
retire_app(app_version)
|
57
|
+
Helper::AirwatchWorkspaceoneHelper.retire_app(app_version, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
|
60
58
|
end
|
61
59
|
UI.success("Version(s) %s successfully retired." % [app_versions.map {|app_version| app_version.values[1]}])
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
65
|
-
def self.find_app(app_identifier)
|
66
|
-
# get the list of apps
|
67
|
-
data = list_app_versions(app_identifier)
|
68
|
-
active_app_versions = Array.new
|
69
|
-
|
70
|
-
data['Application'].each do |app|
|
71
|
-
if app['Status'] == "Active"
|
72
|
-
active_app_version = Hash.new
|
73
|
-
active_app_version['Id'] = app['Id']['Value']
|
74
|
-
active_app_version['Version'] = app['AppVersion']
|
75
|
-
active_app_versions << active_app_version
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
active_app_versions.sort_by! { |app_version| app_version["Id"] }
|
80
|
-
return active_app_versions
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.list_app_versions(app_identifier)
|
84
|
-
require 'rest-client'
|
85
|
-
require 'json'
|
86
|
-
|
87
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
88
|
-
|
89
|
-
if debug
|
90
|
-
UI.message("Response code: %d" % [response.code])
|
91
|
-
UI.message("Response body:")
|
92
|
-
UI.message(JSON.pretty_generate(response.body))
|
93
|
-
end
|
94
|
-
|
95
|
-
if response.code != 200
|
96
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
97
|
-
exit
|
98
|
-
end
|
99
|
-
|
100
|
-
json = JSON.parse(response.body)
|
101
|
-
return json
|
102
|
-
end
|
103
|
-
|
104
|
-
def self.retire_app(app_version)
|
105
|
-
require 'rest-client'
|
106
|
-
require 'json'
|
107
|
-
|
108
|
-
body = {
|
109
|
-
"applicationid" => app_version['Id']
|
110
|
-
}
|
111
|
-
|
112
|
-
UI.message("Starting to retire app version: %s" % [app_version['Version']])
|
113
|
-
response = RestClient.post($host_url + INTERNAL_APP_RETIRE_SUFFIX % [app_version['Id']], body.to_json, {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
114
|
-
|
115
|
-
if debug
|
116
|
-
UI.message("Response code: %d" % [response.code])
|
117
|
-
end
|
118
|
-
|
119
|
-
if response.code == 202
|
120
|
-
UI.message("Successfully retired app version: %s" % [app_version['Version']])
|
121
|
-
else
|
122
|
-
json = JSON.parse(response.body)
|
123
|
-
UI.message("Failed to retire app version: %s" % [app_version['Version']])
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
63
|
def self.description
|
128
64
|
"The main purpose of this action is to retire previous active versions of an application. This action takes a string parameter where you can specify the number of latest versions to keep if you do not want to retire all the previous active versions."
|
129
65
|
end
|
@@ -170,6 +106,15 @@ module Fastlane
|
|
170
106
|
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
171
107
|
end),
|
172
108
|
|
109
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
110
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
111
|
+
description: "Organization Group ID integer identifying the customer or container",
|
112
|
+
optional: false,
|
113
|
+
type: String,
|
114
|
+
verify_block: proc do |value|
|
115
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
116
|
+
end),
|
117
|
+
|
173
118
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
174
119
|
env_name: "APP_IDENTIFIER",
|
175
120
|
description: "Bundle identifier of your app",
|
@@ -5,9 +5,6 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class RetireSpecificVersionAction < Action
|
7
7
|
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
|
9
|
-
INTERNAL_APP_RETIRE_SUFFIX = "/API/mam/apps/internal/%d/retire"
|
10
|
-
|
11
8
|
$is_debug = false
|
12
9
|
|
13
10
|
def self.run(params)
|
@@ -23,6 +20,7 @@ module Fastlane
|
|
23
20
|
UI.message(" host_url: #{params[:host_url]}")
|
24
21
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
25
22
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
23
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
26
24
|
UI.message(" app_identifier: #{params[:app_identifier]}")
|
27
25
|
UI.message(" version_number: #{params[:version_number]}")
|
28
26
|
end
|
@@ -30,6 +28,7 @@ module Fastlane
|
|
30
28
|
$host_url = params[:host_url]
|
31
29
|
$aw_tenant_code = params[:aw_tenant_code]
|
32
30
|
$b64_encoded_auth = params[:b64_encoded_auth]
|
31
|
+
$org_group_id = params[:org_group_id]
|
33
32
|
app_identifier = params[:app_identifier]
|
34
33
|
version_number = params[:version_number]
|
35
34
|
|
@@ -38,7 +37,7 @@ module Fastlane
|
|
38
37
|
UI.message("1. Finding active app versions")
|
39
38
|
UI.message("------------------------------")
|
40
39
|
|
41
|
-
app_versions =
|
40
|
+
app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'Active', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
42
41
|
app_version_numbers = app_versions.map {|app_version| app_version.values[1]}
|
43
42
|
UI.success("Found %d active app version(s)" % [app_versions.count])
|
44
43
|
UI.success("Version number(s): %s" % [app_version_numbers])
|
@@ -51,7 +50,7 @@ module Fastlane
|
|
51
50
|
if app_version_numbers.include? version_number
|
52
51
|
version_index = app_version_numbers.index(version_number)
|
53
52
|
app_version_to_retire = app_versions[version_index]
|
54
|
-
retire_app(app_version_to_retire)
|
53
|
+
Helper::AirwatchWorkspaceoneHelper.retire_app(app_version_to_retire, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
|
55
54
|
else
|
56
55
|
UI.user_error!("A version with the given version number: %s does not exist on the console for this application or is already retired." % [version_number])
|
57
56
|
end
|
@@ -59,68 +58,6 @@ module Fastlane
|
|
59
58
|
UI.success("Version %s successfully retired" % [version_number])
|
60
59
|
end
|
61
60
|
|
62
|
-
def self.find_app(app_identifier)
|
63
|
-
# get the list of apps
|
64
|
-
data = list_app_versions(app_identifier)
|
65
|
-
active_app_versions = Array.new
|
66
|
-
|
67
|
-
data['Application'].each do |app|
|
68
|
-
if app['Status'] == "Active"
|
69
|
-
active_app_version = Hash.new
|
70
|
-
active_app_version['Id'] = app['Id']['Value']
|
71
|
-
active_app_version['Version'] = app['AppVersion']
|
72
|
-
active_app_versions << active_app_version
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
active_app_versions.sort_by! { |app_version| app_version["Id"] }
|
77
|
-
return active_app_versions
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.list_app_versions(app_identifier)
|
81
|
-
require 'rest-client'
|
82
|
-
require 'json'
|
83
|
-
|
84
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
85
|
-
|
86
|
-
if debug
|
87
|
-
UI.message("Response code: %d" % [response.code])
|
88
|
-
UI.message("Response body:")
|
89
|
-
UI.message(response.body)
|
90
|
-
end
|
91
|
-
|
92
|
-
if response.code != 200
|
93
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
94
|
-
exit
|
95
|
-
end
|
96
|
-
|
97
|
-
json = JSON.parse(response.body)
|
98
|
-
return json
|
99
|
-
end
|
100
|
-
|
101
|
-
def self.retire_app(app_version)
|
102
|
-
require 'rest-client'
|
103
|
-
require 'json'
|
104
|
-
|
105
|
-
body = {
|
106
|
-
"applicationid" => app_version['Id']
|
107
|
-
}
|
108
|
-
|
109
|
-
UI.message("Starting to retire app version: %s" % [app_version['Version']])
|
110
|
-
response = RestClient.post($host_url + INTERNAL_APP_RETIRE_SUFFIX % [app_version['Id']], body.to_json, {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
111
|
-
|
112
|
-
if debug
|
113
|
-
UI.message("Response code: %d" % [response.code])
|
114
|
-
end
|
115
|
-
|
116
|
-
if response.code == 202
|
117
|
-
UI.message("Successfully retired app version: %s" % [app_version['Version']])
|
118
|
-
else
|
119
|
-
json = JSON.parse(response.body)
|
120
|
-
UI.message("Failed to retire app version: %s" % [app_version['Version']])
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
61
|
def self.description
|
125
62
|
"The main purpose of this action is to retire a specific version of an application. This action takes a string parameter where you can specify the version number to retire."
|
126
63
|
end
|
@@ -167,6 +104,15 @@ module Fastlane
|
|
167
104
|
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
168
105
|
end),
|
169
106
|
|
107
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
108
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
109
|
+
description: "Organization Group ID integer identifying the customer or container",
|
110
|
+
optional: false,
|
111
|
+
type: String,
|
112
|
+
verify_block: proc do |value|
|
113
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
114
|
+
end),
|
115
|
+
|
170
116
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
171
117
|
env_name: "APP_IDENTIFIER",
|
172
118
|
description: "Bundle identifier of your app",
|
@@ -5,9 +5,6 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class UnretireAllVersionsAction < Action
|
7
7
|
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
|
9
|
-
INTERNAL_APP_UNRETIRE_SUFFIX = "/API/mam/apps/internal/%d/unretire"
|
10
|
-
|
11
8
|
$is_debug = false
|
12
9
|
|
13
10
|
def self.run(params)
|
@@ -23,12 +20,14 @@ module Fastlane
|
|
23
20
|
UI.message(" host_url: #{params[:host_url]}")
|
24
21
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
25
22
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
23
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
26
24
|
UI.message(" app_identifier: #{params[:app_identifier]}")
|
27
25
|
end
|
28
26
|
|
29
27
|
$host_url = params[:host_url]
|
30
28
|
$aw_tenant_code = params[:aw_tenant_code]
|
31
29
|
$b64_encoded_auth = params[:b64_encoded_auth]
|
30
|
+
$org_group_id = params[:org_group_id]
|
32
31
|
app_identifier = params[:app_identifier]
|
33
32
|
|
34
33
|
# step 1: find app
|
@@ -36,7 +35,7 @@ module Fastlane
|
|
36
35
|
UI.message("1. Finding retired app versions")
|
37
36
|
UI.message("-------------------------------")
|
38
37
|
|
39
|
-
retired_app_versions =
|
38
|
+
retired_app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'Retired', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
40
39
|
if retired_app_versions.count <= 0
|
41
40
|
UI.important("No retired app versions found for application with bundle identifier given: %s" % [app_identifier])
|
42
41
|
return
|
@@ -51,73 +50,11 @@ module Fastlane
|
|
51
50
|
UI.message("----------------------------------")
|
52
51
|
|
53
52
|
retired_app_versions.each do |retired_app_version|
|
54
|
-
unretire_app(retired_app_version)
|
53
|
+
Helper::AirwatchWorkspaceoneHelper.unretire_app(retired_app_version, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
|
55
54
|
end
|
56
55
|
UI.success("Version(s) %s successfully unretired." % [retired_app_versions.map {|retired_app_version| retired_app_version.values[1]}])
|
57
56
|
end
|
58
57
|
|
59
|
-
def self.find_app(app_identifier)
|
60
|
-
# get the list of apps
|
61
|
-
data = list_app_versions(app_identifier)
|
62
|
-
retired_app_versions = Array.new
|
63
|
-
|
64
|
-
data['Application'].each do |app|
|
65
|
-
if app['Status'] == "Retired"
|
66
|
-
retired_app_version = Hash.new
|
67
|
-
retired_app_version['Id'] = app['Id']['Value']
|
68
|
-
retired_app_version['Version'] = app['AppVersion']
|
69
|
-
retired_app_versions << retired_app_version
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
retired_app_versions.sort_by! { |app_version| app_version["Id"] }
|
74
|
-
return retired_app_versions
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.list_app_versions(app_identifier)
|
78
|
-
require 'rest-client'
|
79
|
-
require 'json'
|
80
|
-
|
81
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
82
|
-
|
83
|
-
if debug
|
84
|
-
UI.message("Response code: %d" % [response.code])
|
85
|
-
UI.message("Response body:")
|
86
|
-
UI.message(response.body)
|
87
|
-
end
|
88
|
-
|
89
|
-
if response.code != 200
|
90
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
91
|
-
exit
|
92
|
-
end
|
93
|
-
|
94
|
-
json = JSON.parse(response.body)
|
95
|
-
return json
|
96
|
-
end
|
97
|
-
|
98
|
-
def self.unretire_app(app_version)
|
99
|
-
require 'rest-client'
|
100
|
-
require 'json'
|
101
|
-
|
102
|
-
body = {
|
103
|
-
"applicationid" => app_version['Id']
|
104
|
-
}
|
105
|
-
|
106
|
-
UI.message("Starting to unretire app version: %s" % [app_version['Version']])
|
107
|
-
response = RestClient.post($host_url + INTERNAL_APP_UNRETIRE_SUFFIX % [app_version['Id']], body.to_json, {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
108
|
-
|
109
|
-
if debug
|
110
|
-
UI.message("Response code: %d" % [response.code])
|
111
|
-
end
|
112
|
-
|
113
|
-
if response.code == 202
|
114
|
-
UI.message("Successfully unretired app version: %s" % [app_version['Version']])
|
115
|
-
else
|
116
|
-
json = JSON.parse(response.body)
|
117
|
-
UI.message("Failed to unretire app version: %s" % [app_version['Version']])
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
58
|
def self.description
|
122
59
|
"The main purpose of this action is to unretire all retired versions of an application."
|
123
60
|
end
|
@@ -164,6 +101,15 @@ module Fastlane
|
|
164
101
|
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
165
102
|
end),
|
166
103
|
|
104
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
105
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
106
|
+
description: "Organization Group ID integer identifying the customer or container",
|
107
|
+
optional: false,
|
108
|
+
type: String,
|
109
|
+
verify_block: proc do |value|
|
110
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
111
|
+
end),
|
112
|
+
|
167
113
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
168
114
|
env_name: "APP_IDENTIFIER",
|
169
115
|
description: "Bundle identifier of your app",
|
@@ -5,9 +5,6 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class UnretireSpecificVersionAction < Action
|
7
7
|
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
|
9
|
-
INTERNAL_APP_UNRETIRE_SUFFIX = "/API/mam/apps/internal/%d/unretire"
|
10
|
-
|
11
8
|
$is_debug = false
|
12
9
|
|
13
10
|
def self.run(params)
|
@@ -23,6 +20,7 @@ module Fastlane
|
|
23
20
|
UI.message(" host_url: #{params[:host_url]}")
|
24
21
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
25
22
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
23
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
26
24
|
UI.message(" app_identifier: #{params[:app_identifier]}")
|
27
25
|
UI.message(" version_number: #{params[:version_number]}")
|
28
26
|
end
|
@@ -30,6 +28,7 @@ module Fastlane
|
|
30
28
|
$host_url = params[:host_url]
|
31
29
|
$aw_tenant_code = params[:aw_tenant_code]
|
32
30
|
$b64_encoded_auth = params[:b64_encoded_auth]
|
31
|
+
$org_group_id = params[:org_group_id]
|
33
32
|
app_identifier = params[:app_identifier]
|
34
33
|
version_number = params[:version_number]
|
35
34
|
|
@@ -38,7 +37,7 @@ module Fastlane
|
|
38
37
|
UI.message("1. Finding retired app versions")
|
39
38
|
UI.message("-------------------------------")
|
40
39
|
|
41
|
-
retired_app_versions =
|
40
|
+
retired_app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'Retired', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
42
41
|
if retired_app_versions.count <= 0
|
43
42
|
UI.important("No retired app versions found for application with bundle identifier given: %s" % [app_identifier])
|
44
43
|
return
|
@@ -56,7 +55,7 @@ module Fastlane
|
|
56
55
|
if retired_version_numbers.include? version_number
|
57
56
|
version_index = retired_version_numbers.index(version_number)
|
58
57
|
app_version_to_unretire = retired_app_versions[version_index]
|
59
|
-
unretire_app(app_version_to_unretire)
|
58
|
+
Helper::AirwatchWorkspaceoneHelper.unretire_app(app_version_to_unretire, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
|
60
59
|
else
|
61
60
|
UI.user_error!("A version with the given version number: %s does not exist on the console for this application or is already Active." % [version_number])
|
62
61
|
end
|
@@ -64,68 +63,6 @@ module Fastlane
|
|
64
63
|
UI.success("Version %s successfully unretired" % [version_number])
|
65
64
|
end
|
66
65
|
|
67
|
-
def self.find_app(app_identifier)
|
68
|
-
# get the list of apps
|
69
|
-
data = list_app_versions(app_identifier)
|
70
|
-
retired_app_versions = Array.new
|
71
|
-
|
72
|
-
data['Application'].each do |app|
|
73
|
-
if app['Status'] == "Retired"
|
74
|
-
retired_app_version = Hash.new
|
75
|
-
retired_app_version['Id'] = app['Id']['Value']
|
76
|
-
retired_app_version['Version'] = app['AppVersion']
|
77
|
-
retired_app_versions << retired_app_version
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
retired_app_versions.sort_by! { |app_version| app_version["Id"] }
|
82
|
-
return retired_app_versions
|
83
|
-
end
|
84
|
-
|
85
|
-
def self.list_app_versions(app_identifier)
|
86
|
-
require 'rest-client'
|
87
|
-
require 'json'
|
88
|
-
|
89
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
90
|
-
|
91
|
-
if debug
|
92
|
-
UI.message("Response code: %d" % [response.code])
|
93
|
-
UI.message("Response body:")
|
94
|
-
UI.message(response.body)
|
95
|
-
end
|
96
|
-
|
97
|
-
if response.code != 200
|
98
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
99
|
-
exit
|
100
|
-
end
|
101
|
-
|
102
|
-
json = JSON.parse(response.body)
|
103
|
-
return json
|
104
|
-
end
|
105
|
-
|
106
|
-
def self.unretire_app(app_version)
|
107
|
-
require 'rest-client'
|
108
|
-
require 'json'
|
109
|
-
|
110
|
-
body = {
|
111
|
-
"applicationid" => app_version['Id']
|
112
|
-
}
|
113
|
-
|
114
|
-
UI.message("Starting to unretire app version: %s" % [app_version['Version']])
|
115
|
-
response = RestClient.post($host_url + INTERNAL_APP_UNRETIRE_SUFFIX % [app_version['Id']], body.to_json, {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
116
|
-
|
117
|
-
if debug
|
118
|
-
UI.message("Response code: %d" % [response.code])
|
119
|
-
end
|
120
|
-
|
121
|
-
if response.code == 202
|
122
|
-
UI.message("Successfully unretired app version: %s" % [app_version['Version']])
|
123
|
-
else
|
124
|
-
json = JSON.parse(response.body)
|
125
|
-
UI.message("Failed to unretire app version: %s" % [app_version['Version']])
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
66
|
def self.description
|
130
67
|
"The main purpose of this action is to unretire a specific version of an application. This action takes a string parameter where you can specify the version number to unretire."
|
131
68
|
end
|
@@ -172,6 +109,15 @@ module Fastlane
|
|
172
109
|
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
173
110
|
end),
|
174
111
|
|
112
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
113
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
114
|
+
description: "Organization Group ID integer identifying the customer or container",
|
115
|
+
optional: false,
|
116
|
+
type: String,
|
117
|
+
verify_block: proc do |value|
|
118
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
119
|
+
end),
|
120
|
+
|
175
121
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
176
122
|
env_name: "APP_IDENTIFIER",
|
177
123
|
description: "Bundle identifier of your app",
|
@@ -8,9 +8,138 @@ module Fastlane
|
|
8
8
|
# class methods that you define here become available in your action
|
9
9
|
# as `Helper::AirwatchWorkspaceoneHelper.your_method`
|
10
10
|
#
|
11
|
+
|
12
|
+
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&includeAppsFromChildOgs=false&IncludeAppsFromParentOgs=false&bundleid=%s&locationgroupid=%d"
|
13
|
+
INTERNAL_APP_DELETE_SUFFIX = "/API/mam/apps/internal/%d"
|
14
|
+
INTERNAL_APP_RETIRE_SUFFIX = "/API/mam/apps/internal/%d/retire"
|
15
|
+
INTERNAL_APP_UNRETIRE_SUFFIX = "/API/mam/apps/internal/%d/unretire"
|
16
|
+
|
11
17
|
def self.show_message
|
12
18
|
UI.message("Hello from the airwatch_workspaceone plugin helper!")
|
13
19
|
end
|
20
|
+
|
21
|
+
def self.construct_app_version(app)
|
22
|
+
app_version = Hash.new
|
23
|
+
app_version['Id'] = app['Id']['Value']
|
24
|
+
app_version['Version'] = app['AppVersion']
|
25
|
+
return app_version
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.find_app_versions(app_identifier, app_status, host_url, aw_tenant_code, b64_encoded_auth, locationGrpId, debug)
|
29
|
+
# get the list of apps
|
30
|
+
apps = list_app_versions(app_identifier, host_url, aw_tenant_code, b64_encoded_auth, locationGrpId, debug)
|
31
|
+
app_versions = Array.new
|
32
|
+
|
33
|
+
apps['Application'].each do |app|
|
34
|
+
|
35
|
+
case app_status
|
36
|
+
when 'Active'
|
37
|
+
if app['Status'] == "Active"
|
38
|
+
app_version = construct_app_version(app)
|
39
|
+
app_versions << app_version
|
40
|
+
end
|
41
|
+
|
42
|
+
when 'Retired'
|
43
|
+
if app['Status'] == "Retired"
|
44
|
+
app_version = construct_app_version(app)
|
45
|
+
app_versions << app_version
|
46
|
+
end
|
47
|
+
|
48
|
+
else
|
49
|
+
app_version = construct_app_version(app)
|
50
|
+
app_versions << app_version
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
app_versions.sort_by! { |app_version| app_version["Id"] }
|
55
|
+
return app_versions
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.list_app_versions(app_identifier, host_url, aw_tenant_code, b64_encoded_auth, locationGrpId, debug)
|
59
|
+
require 'rest-client'
|
60
|
+
require 'json'
|
61
|
+
|
62
|
+
response = RestClient.get(host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier, locationGrpId], {accept: :json, 'aw-tenant-code': aw_tenant_code, 'Authorization': "Basic " + b64_encoded_auth})
|
63
|
+
|
64
|
+
if debug
|
65
|
+
UI.message("Response code: %d" % [response.code])
|
66
|
+
UI.message("Response body:")
|
67
|
+
UI.message(JSON.pretty_generate(response.body))
|
68
|
+
end
|
69
|
+
|
70
|
+
if response.code != 200
|
71
|
+
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
72
|
+
exit
|
73
|
+
end
|
74
|
+
|
75
|
+
json = JSON.parse(response.body)
|
76
|
+
return json
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.delete_app(app_version, host_url, aw_tenant_code, b64_encoded_auth, debug)
|
80
|
+
require 'rest-client'
|
81
|
+
require 'json'
|
82
|
+
|
83
|
+
UI.message("Starting to delete app version: %s" % [app_version['Version']])
|
84
|
+
response = RestClient.delete(host_url + INTERNAL_APP_DELETE_SUFFIX % [app_version['Id']], {accept: :json, 'aw-tenant-code': aw_tenant_code, 'Authorization': "Basic " + b64_encoded_auth})
|
85
|
+
|
86
|
+
if debug
|
87
|
+
UI.message("Response code: %d" % [response.code])
|
88
|
+
end
|
89
|
+
|
90
|
+
if response.code == 204
|
91
|
+
UI.message("Successfully deleted app version: %s" % [app_version['Version']])
|
92
|
+
else
|
93
|
+
UI.message("Failed to delete app version: %s" % [app_version['Version']])
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.retire_app(app_version, host_url, aw_tenant_code, b64_encoded_auth, debug)
|
98
|
+
require 'rest-client'
|
99
|
+
require 'json'
|
100
|
+
|
101
|
+
body = {
|
102
|
+
"applicationid" => app_version['Id']
|
103
|
+
}
|
104
|
+
|
105
|
+
UI.message("Starting to retire app version: %s" % [app_version['Version']])
|
106
|
+
response = RestClient.post(host_url + INTERNAL_APP_RETIRE_SUFFIX % [app_version['Id']], body.to_json, {accept: :json, 'aw-tenant-code': aw_tenant_code, 'Authorization': "Basic " + b64_encoded_auth})
|
107
|
+
|
108
|
+
if debug
|
109
|
+
UI.message("Response code: %d" % [response.code])
|
110
|
+
end
|
111
|
+
|
112
|
+
if response.code == 202
|
113
|
+
UI.message("Successfully retired app version: %s" % [app_version['Version']])
|
114
|
+
else
|
115
|
+
json = JSON.parse(response.body)
|
116
|
+
UI.message("Failed to retire app version: %s" % [app_version['Version']])
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.unretire_app(app_version, host_url, aw_tenant_code, b64_encoded_auth, debug)
|
121
|
+
require 'rest-client'
|
122
|
+
require 'json'
|
123
|
+
|
124
|
+
body = {
|
125
|
+
"applicationid" => app_version['Id']
|
126
|
+
}
|
127
|
+
|
128
|
+
UI.message("Starting to unretire app version: %s" % [app_version['Version']])
|
129
|
+
response = RestClient.post(host_url + INTERNAL_APP_UNRETIRE_SUFFIX % [app_version['Id']], body.to_json, {accept: :json, 'aw-tenant-code': aw_tenant_code, 'Authorization': "Basic " + b64_encoded_auth})
|
130
|
+
|
131
|
+
if debug
|
132
|
+
UI.message("Response code: %d" % [response.code])
|
133
|
+
end
|
134
|
+
|
135
|
+
if response.code == 202
|
136
|
+
UI.message("Successfully unretired app version: %s" % [app_version['Version']])
|
137
|
+
else
|
138
|
+
json = JSON.parse(response.body)
|
139
|
+
UI.message("Failed to unretire app version: %s" % [app_version['Version']])
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
14
143
|
end
|
15
144
|
end
|
16
|
-
end
|
145
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-airwatch_workspaceone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ram Awadhesh Sharan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/fastlane/plugin/airwatch_workspaceone/actions/delete_previous_versions_action.rb
|
178
178
|
- lib/fastlane/plugin/airwatch_workspaceone/actions/delete_specific_version_action.rb
|
179
179
|
- lib/fastlane/plugin/airwatch_workspaceone/actions/deploy_build_action.rb
|
180
|
+
- lib/fastlane/plugin/airwatch_workspaceone/actions/latest_version_action.rb
|
180
181
|
- lib/fastlane/plugin/airwatch_workspaceone/actions/retire_previous_versions_action.rb
|
181
182
|
- lib/fastlane/plugin/airwatch_workspaceone/actions/retire_specific_version_action.rb
|
182
183
|
- lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_all_versions.rb
|