fastlane-plugin-airwatch_workspaceone 2.0.0 → 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/README.md +19 -4
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/add_or_update_assignments_action.rb +16 -37
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/delete_previous_versions_action.rb +28 -61
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/delete_specific_version_action.rb +22 -68
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/deploy_build_action.rb +74 -17
- 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 +21 -74
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/retire_specific_version_action.rb +20 -73
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_all_versions.rb +20 -73
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb +164 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/helper/airwatch_workspaceone_helper.rb +130 -1
- data/lib/fastlane/plugin/airwatch_workspaceone/version.rb +1 -1
- metadata +9 -7
@@ -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"
|
@@ -27,6 +32,7 @@ module Fastlane
|
|
27
32
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
28
33
|
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
29
34
|
UI.message(" app_name: #{params[:app_name]}")
|
35
|
+
UI.message(" app_version: #{params[:app_version]}")
|
30
36
|
UI.message(" file_name: #{params[:file_name]}")
|
31
37
|
UI.message(" path_to_file: #{params[:path_to_file]}")
|
32
38
|
UI.message(" push_mode: #{params[:push_mode]}")
|
@@ -37,6 +43,7 @@ module Fastlane
|
|
37
43
|
$b64_encoded_auth = params[:b64_encoded_auth]
|
38
44
|
$org_group_id = params[:org_group_id]
|
39
45
|
app_name = params[:app_name]
|
46
|
+
app_version = params[:app_version]
|
40
47
|
file_name = params[:file_name]
|
41
48
|
path_to_file = params[:path_to_file]
|
42
49
|
push_mode = params[:push_mode]
|
@@ -76,10 +83,10 @@ module Fastlane
|
|
76
83
|
end
|
77
84
|
|
78
85
|
# step 4: deploying app version
|
79
|
-
UI.message("
|
86
|
+
UI.message("-----------------------------------")
|
80
87
|
UI.message("4. Deploying app version on console")
|
81
|
-
UI.message("
|
82
|
-
deploy_app(blobID, app_name, push_mode)
|
88
|
+
UI.message("-----------------------------------")
|
89
|
+
deploy_app(blobID, app_name, app_version, push_mode)
|
83
90
|
UI.success("Successfully deployed the app version")
|
84
91
|
end
|
85
92
|
|
@@ -126,7 +133,6 @@ module Fastlane
|
|
126
133
|
end
|
127
134
|
|
128
135
|
def self.create_model_for(model_id, model_name)
|
129
|
-
|
130
136
|
model_hash = Hash.new
|
131
137
|
model_hash['ModelId'] = model_id
|
132
138
|
model_hash['ModelName'] = model_name
|
@@ -160,7 +166,7 @@ module Fastlane
|
|
160
166
|
return json['Value']
|
161
167
|
end
|
162
168
|
|
163
|
-
def self.deploy_app(blobID, app_name, push_mode)
|
169
|
+
def self.deploy_app(blobID, app_name, app_version, push_mode)
|
164
170
|
require 'rest-client'
|
165
171
|
require 'json'
|
166
172
|
|
@@ -168,6 +174,7 @@ module Fastlane
|
|
168
174
|
"BlobId" => blobID.to_s,
|
169
175
|
"DeviceType" => $device_type,
|
170
176
|
"ApplicationName" => app_name,
|
177
|
+
"AppVersion" => app_version,
|
171
178
|
"SupportedModels" => $supported_device_models,
|
172
179
|
"PushMode" => push_mode,
|
173
180
|
"LocationGroupId" => $org_group_id
|
@@ -178,7 +185,15 @@ module Fastlane
|
|
178
185
|
UI.message(body.to_json)
|
179
186
|
end
|
180
187
|
|
181
|
-
|
188
|
+
begin
|
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})
|
190
|
+
rescue RestClient::ExceptionWithResponse => e
|
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)
|
195
|
+
raise
|
196
|
+
end
|
182
197
|
|
183
198
|
if debug
|
184
199
|
UI.message("Response code: %d" % [response.code])
|
@@ -187,53 +202,88 @@ module Fastlane
|
|
187
202
|
end
|
188
203
|
|
189
204
|
json = JSON.parse(response.body)
|
205
|
+
Actions.lane_context[SharedValues::DEPLOYED_APP_UUID] = json['Uuid']
|
190
206
|
return json
|
191
207
|
end
|
192
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
|
+
|
193
237
|
def self.description
|
194
|
-
"The main purpose of this action is to upload an IPA or an APK file to an AirWatch or Workspace ONE enterprise
|
238
|
+
"The main purpose of this action is to upload an IPA or an APK file to an AirWatch or Workspace ONE enterprise console."
|
195
239
|
end
|
196
240
|
|
197
241
|
def self.authors
|
198
242
|
["Ram Awadhesh Sharan"]
|
199
243
|
end
|
200
244
|
|
245
|
+
def self.output
|
246
|
+
[
|
247
|
+
['DEPLOYED_APP_UUID', 'The unique identifier of the deployed application in uuid format']
|
248
|
+
]
|
249
|
+
end
|
250
|
+
|
201
251
|
def self.return_value
|
202
252
|
# If your method provides a return value, you can describe here what it does
|
203
253
|
end
|
204
254
|
|
205
255
|
def self.details
|
206
256
|
# Optional:
|
207
|
-
"deploy_build - To upload an iOS ipa OR Android APK to AirWatch/
|
257
|
+
"deploy_build - To upload an iOS ipa OR Android APK to AirWatch/Workspace One console."
|
208
258
|
end
|
209
259
|
|
210
260
|
def self.available_options
|
211
261
|
[
|
212
262
|
FastlaneCore::ConfigItem.new(key: :host_url,
|
213
263
|
env_name: "AIRWATCH_HOST_API_URL",
|
214
|
-
description: "Host API URL of the AirWatch instance",
|
264
|
+
description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
|
215
265
|
optional: false,
|
216
266
|
type: String,
|
217
267
|
verify_block: proc do |value|
|
218
|
-
UI.user_error!("No AirWatch Host API URl given.") unless value and !value.empty?
|
268
|
+
UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
|
219
269
|
end),
|
220
270
|
|
221
271
|
FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
|
222
272
|
env_name: "AIRWATCH_API_KEY",
|
223
|
-
description: "API key or the tenant code to access AirWatch Rest APIs",
|
273
|
+
description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
|
224
274
|
optional: false,
|
225
275
|
type: String,
|
226
276
|
verify_block: proc do |value|
|
227
|
-
UI.user_error!("Api tenant code header is missing
|
277
|
+
UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
|
228
278
|
end),
|
229
279
|
|
230
280
|
FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
|
231
281
|
env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
|
232
|
-
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch instance",
|
282
|
+
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch/Workspace ONE instance",
|
233
283
|
optional: false,
|
234
284
|
type: String,
|
235
285
|
verify_block: proc do |value|
|
236
|
-
UI.user_error!("The authorization header is empty or the scheme is not basic") unless value and !value.empty?
|
286
|
+
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?
|
237
287
|
end),
|
238
288
|
|
239
289
|
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
@@ -242,7 +292,7 @@ module Fastlane
|
|
242
292
|
optional: false,
|
243
293
|
type: String,
|
244
294
|
verify_block: proc do |value|
|
245
|
-
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id:
|
295
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
246
296
|
end),
|
247
297
|
|
248
298
|
FastlaneCore::ConfigItem.new(key: :app_name,
|
@@ -253,6 +303,13 @@ module Fastlane
|
|
253
303
|
verify_block: proc do |value|
|
254
304
|
UI.user_error!("No app name given, pass using `app_name: 'My sample app'`") unless value and !value.empty?
|
255
305
|
end),
|
306
|
+
|
307
|
+
FastlaneCore::ConfigItem.new(key: :app_version,
|
308
|
+
env_name: "AIRWATCH_APPLICATION_VERSION",
|
309
|
+
description: "Airwatch Internal App Version",
|
310
|
+
optional: true,
|
311
|
+
type: String,
|
312
|
+
default_value: nil),
|
256
313
|
|
257
314
|
FastlaneCore::ConfigItem.new(key: :file_name,
|
258
315
|
env_name: "AIRWATCH_FILE_NAME",
|
@@ -274,11 +331,11 @@ module Fastlane
|
|
274
331
|
|
275
332
|
FastlaneCore::ConfigItem.new(key: :push_mode,
|
276
333
|
env_name: "AIRWATCH_APP_PUSH_MODE",
|
277
|
-
description: "Push mode for the application",
|
334
|
+
description: "Push mode for the application. Values are Auto or On demand",
|
278
335
|
optional: false,
|
279
336
|
type: String,
|
280
337
|
verify_block: proc do |value|
|
281
|
-
UI.user_error!("No push mode given, pass using `push_mode: 'Auto'` or
|
338
|
+
UI.user_error!("No push mode given, pass using `push_mode: 'Auto'` or `push_mode: 'On demand'`") unless value and !value.empty?
|
282
339
|
end),
|
283
340
|
|
284
341
|
FastlaneCore::ConfigItem.new(key: :debug,
|
@@ -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?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,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 active app versions")
|
39
38
|
UI.message("------------------------------")
|
40
39
|
|
41
|
-
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)
|
42
41
|
UI.success("Found %d active 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,73 +54,12 @@ module Fastlane
|
|
55
54
|
app_versions.pop(keep_latest_versions_count_int)
|
56
55
|
UI.important("Version number(s) to retire: %s" % [app_versions.map {|app_version| app_version.values[1]}])
|
57
56
|
app_versions.each do |app_version|
|
58
|
-
retire_app(app_version)
|
57
|
+
Helper::AirwatchWorkspaceoneHelper.retire_app(app_version, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
|
59
58
|
end
|
60
59
|
UI.success("Version(s) %s successfully retired." % [app_versions.map {|app_version| app_version.values[1]}])
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
64
|
-
def self.find_app(app_identifier)
|
65
|
-
# get the list of apps
|
66
|
-
data = list_app_versions(app_identifier)
|
67
|
-
active_app_versions = Array.new
|
68
|
-
|
69
|
-
data['Application'].each do |app|
|
70
|
-
if app['Status'] == "Active"
|
71
|
-
active_app_version = Hash.new
|
72
|
-
active_app_version['Id'] = app['Id']['Value']
|
73
|
-
active_app_version['Version'] = app['AppVersion']
|
74
|
-
active_app_versions << active_app_version
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
return active_app_versions
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.list_app_versions(app_identifier)
|
82
|
-
require 'rest-client'
|
83
|
-
require 'json'
|
84
|
-
|
85
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
86
|
-
|
87
|
-
if debug
|
88
|
-
UI.message("Response code: %d" % [response.code])
|
89
|
-
UI.message("Response body:")
|
90
|
-
UI.message(response.body)
|
91
|
-
end
|
92
|
-
|
93
|
-
if response.code != 200
|
94
|
-
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.")
|
95
|
-
exit
|
96
|
-
end
|
97
|
-
|
98
|
-
json = JSON.parse(response.body)
|
99
|
-
return json
|
100
|
-
end
|
101
|
-
|
102
|
-
def self.retire_app(app_version)
|
103
|
-
require 'rest-client'
|
104
|
-
require 'json'
|
105
|
-
|
106
|
-
body = {
|
107
|
-
"applicationid" => app_version['Id']
|
108
|
-
}
|
109
|
-
|
110
|
-
UI.message("Starting to retire app version: %s" % [app_version['Version']])
|
111
|
-
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})
|
112
|
-
|
113
|
-
if debug
|
114
|
-
UI.message("Response code: %d" % [response.code])
|
115
|
-
end
|
116
|
-
|
117
|
-
if response.code == 202
|
118
|
-
UI.message("Successfully retired app version: %s" % [app_version['Version']])
|
119
|
-
else
|
120
|
-
json = JSON.parse(response.body)
|
121
|
-
UI.message("Failed to retire app version: %s" % [app_version['Version']])
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
63
|
def self.description
|
126
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."
|
127
65
|
end
|
@@ -136,36 +74,45 @@ module Fastlane
|
|
136
74
|
|
137
75
|
def self.details
|
138
76
|
# Optional:
|
139
|
-
"retire_previous_versions - To retire previous active versions of an application on the AirWatch console except the latest version."
|
77
|
+
"retire_previous_versions - To retire previous active versions of an application on the AirWatch/Workspace ONE console except the latest version."
|
140
78
|
end
|
141
79
|
|
142
80
|
def self.available_options
|
143
81
|
[
|
144
82
|
FastlaneCore::ConfigItem.new(key: :host_url,
|
145
83
|
env_name: "AIRWATCH_HOST_API_URL",
|
146
|
-
description: "Host API URL of the AirWatch instance",
|
84
|
+
description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
|
147
85
|
optional: false,
|
148
86
|
type: String,
|
149
87
|
verify_block: proc do |value|
|
150
|
-
UI.user_error!("No AirWatch Host API URl given.") unless value and !value.empty?
|
88
|
+
UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
|
151
89
|
end),
|
152
90
|
|
153
91
|
FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
|
154
92
|
env_name: "AIRWATCH_API_KEY",
|
155
|
-
description: "API key to access AirWatch Rest APIs",
|
93
|
+
description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
|
156
94
|
optional: false,
|
157
95
|
type: String,
|
158
96
|
verify_block: proc do |value|
|
159
|
-
UI.user_error!("Api tenant code header is missing
|
97
|
+
UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
|
160
98
|
end),
|
161
99
|
|
162
100
|
FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
|
163
101
|
env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
|
164
|
-
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch instance",
|
102
|
+
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch/Workspace ONE instance",
|
103
|
+
optional: false,
|
104
|
+
type: String,
|
105
|
+
verify_block: proc do |value|
|
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?
|
107
|
+
end),
|
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",
|
165
112
|
optional: false,
|
166
113
|
type: String,
|
167
114
|
verify_block: proc do |value|
|
168
|
-
UI.user_error!("
|
115
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
169
116
|
end),
|
170
117
|
|
171
118
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
@@ -184,7 +131,7 @@ module Fastlane
|
|
184
131
|
type: String,
|
185
132
|
default_value: "1",
|
186
133
|
verify_block: proc do |value|
|
187
|
-
UI.user_error!("The number of latest versions to keep can not be
|
134
|
+
UI.user_error!("The number of latest versions to keep can not be negative, pass using `keep_latest_versions_count: 'count'`") unless value.to_i > 0
|
188
135
|
end),
|
189
136
|
|
190
137
|
FastlaneCore::ConfigItem.new(key: :debug,
|