fastlane-plugin-airwatch_workspaceone 1.0.2 → 2.0.0
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 +4 -4
- data/README.md +25 -7
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/add_or_update_assignments_action.rb +310 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/delete_previous_versions_action.rb +219 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/delete_specific_version_action.rb +205 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/deploy_build_action.rb +42 -43
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/retire_previous_versions_action.rb +60 -48
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/retire_specific_version_action.rb +212 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_all_versions.rb +200 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/version.rb +1 -1
- metadata +7 -2
@@ -0,0 +1,205 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/airwatch_workspaceone_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class DeleteSpecificVersionAction < Action
|
7
|
+
|
8
|
+
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?bundleid=%s"
|
9
|
+
INTERNAL_APP_DELETE_SUFFIX = "/API/mam/apps/internal/%d"
|
10
|
+
|
11
|
+
$is_debug = false
|
12
|
+
|
13
|
+
def self.run(params)
|
14
|
+
UI.message("The airwatch_workspaceone plugin is working!")
|
15
|
+
|
16
|
+
# check if debug is enabled
|
17
|
+
$is_debug = params[:debug]
|
18
|
+
|
19
|
+
if debug
|
20
|
+
UI.message("---------------------------------------------")
|
21
|
+
UI.message("DeleteSpecificVersionAction debug information")
|
22
|
+
UI.message("---------------------------------------------")
|
23
|
+
UI.message(" host_url: #{params[:host_url]}")
|
24
|
+
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
25
|
+
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
26
|
+
UI.message(" app_identifier: #{params[:app_identifier]}")
|
27
|
+
UI.message(" version_number: #{params[:version_number]}")
|
28
|
+
end
|
29
|
+
|
30
|
+
$host_url = params[:host_url]
|
31
|
+
$aw_tenant_code = params[:aw_tenant_code]
|
32
|
+
$b64_encoded_auth = params[:b64_encoded_auth]
|
33
|
+
app_identifier = params[:app_identifier]
|
34
|
+
version_number = params[:version_number]
|
35
|
+
|
36
|
+
# step 1: find app
|
37
|
+
UI.message("-----------------------")
|
38
|
+
UI.message("1. Finding app versions")
|
39
|
+
UI.message("-----------------------")
|
40
|
+
|
41
|
+
app_versions = find_app(app_identifier)
|
42
|
+
app_version_numbers = app_versions.map {|app_version| app_version.values[1]}
|
43
|
+
UI.success("Found %d app version(s)" % [app_versions.count])
|
44
|
+
UI.success("Version number(s): %s" % [app_version_numbers])
|
45
|
+
|
46
|
+
# step 2: delete specific version
|
47
|
+
UI.message("--------------------------------")
|
48
|
+
UI.message("2. Deleting specific app version")
|
49
|
+
UI.message("--------------------------------")
|
50
|
+
|
51
|
+
if app_version_numbers.include? version_number
|
52
|
+
version_index = app_version_numbers.index(version_number)
|
53
|
+
app_version_to_delete = app_versions[version_index]
|
54
|
+
delete_app(app_version_to_delete)
|
55
|
+
else
|
56
|
+
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
|
+
end
|
58
|
+
|
59
|
+
UI.success("Version %s successfully deleted" % [version_number])
|
60
|
+
end
|
61
|
+
|
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
|
+
return 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.delete_app(app_version)
|
99
|
+
require 'rest-client'
|
100
|
+
require 'json'
|
101
|
+
|
102
|
+
UI.message("Starting to delete app version: %s" % [app_version['Version']])
|
103
|
+
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})
|
104
|
+
|
105
|
+
if debug
|
106
|
+
UI.message("Response code: %d" % [response.code])
|
107
|
+
end
|
108
|
+
|
109
|
+
if response.code == 204
|
110
|
+
UI.message("Successfully deleted app version: %s" % [app_version['Version']])
|
111
|
+
else
|
112
|
+
UI.message("Failed to delete app version: %s" % [app_version['Version']])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.description
|
117
|
+
"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."
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.authors
|
121
|
+
["Ram Awadhesh Sharan"]
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.return_value
|
125
|
+
# If your method provides a return value, you can describe here what it does
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.details
|
129
|
+
# Optional:
|
130
|
+
"delete_specific_version - To delete specific version of an application on the AirWatch console."
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.available_options
|
134
|
+
[
|
135
|
+
FastlaneCore::ConfigItem.new(key: :host_url,
|
136
|
+
env_name: "AIRWATCH_HOST_API_URL",
|
137
|
+
description: "Host API URL of the AirWatch instance",
|
138
|
+
optional: false,
|
139
|
+
type: String,
|
140
|
+
verify_block: proc do |value|
|
141
|
+
UI.user_error!("No AirWatch Host API URl given.") unless value and !value.empty?
|
142
|
+
end),
|
143
|
+
|
144
|
+
FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
|
145
|
+
env_name: "AIRWATCH_API_KEY",
|
146
|
+
description: "API key to access AirWatch Rest APIs",
|
147
|
+
optional: false,
|
148
|
+
type: String,
|
149
|
+
verify_block: proc do |value|
|
150
|
+
UI.user_error!("Api tenant code header is missing.") unless value and !value.empty?
|
151
|
+
end),
|
152
|
+
|
153
|
+
FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
|
154
|
+
env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
|
155
|
+
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch instance",
|
156
|
+
optional: false,
|
157
|
+
type: String,
|
158
|
+
verify_block: proc do |value|
|
159
|
+
UI.user_error!("The authorization header is empty or the scheme is not basic") unless value and !value.empty?
|
160
|
+
end),
|
161
|
+
|
162
|
+
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
163
|
+
env_name: "APP_IDENTIFIER",
|
164
|
+
description: "Bundle identifier of your app",
|
165
|
+
optional: false,
|
166
|
+
type: String,
|
167
|
+
verify_block: proc do |value|
|
168
|
+
UI.user_error!("No app identifier given, pass using `app_identifier: 'com.example.app'`") unless value and !value.empty?
|
169
|
+
end),
|
170
|
+
|
171
|
+
FastlaneCore::ConfigItem.new(key: :version_number,
|
172
|
+
env_name: "AIRWATCH_VERSION_NUMBER",
|
173
|
+
description: "Version number of the application to retire",
|
174
|
+
optional: false,
|
175
|
+
type: String,
|
176
|
+
verify_block: proc do |value|
|
177
|
+
UI.user_error!("No version number given, pass using `version_number: '1.0'`") unless value and !value.empty?
|
178
|
+
end),
|
179
|
+
|
180
|
+
FastlaneCore::ConfigItem.new(key: :debug,
|
181
|
+
env_name: "AIRWATCH_DEBUG",
|
182
|
+
description: "Debug flag, set to true to show extended output. default: false",
|
183
|
+
optional: true,
|
184
|
+
is_string: false,
|
185
|
+
default_value: false)
|
186
|
+
]
|
187
|
+
end
|
188
|
+
|
189
|
+
def self.is_supported?(platform)
|
190
|
+
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
191
|
+
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
192
|
+
|
193
|
+
[:ios, :android].include?(platform)
|
194
|
+
true
|
195
|
+
end
|
196
|
+
|
197
|
+
# helpers
|
198
|
+
|
199
|
+
def self.debug
|
200
|
+
$is_debug
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -5,12 +5,12 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class DeployBuildAction < Action
|
7
7
|
|
8
|
-
UPLOAD_BLOB_SUFFIX
|
9
|
-
BEGIN_INSTALL_SUFFIX
|
8
|
+
UPLOAD_BLOB_SUFFIX = "/API/mam/blobs/uploadblob?fileName=%s&organizationGroupId=%s"
|
9
|
+
BEGIN_INSTALL_SUFFIX = "/API/mam/apps/internal/begininstall"
|
10
10
|
|
11
|
-
$is_debug
|
12
|
-
$device_type
|
13
|
-
$supported_device_models
|
11
|
+
$is_debug = false
|
12
|
+
$device_type = "Apple"
|
13
|
+
$supported_device_models = Hash.new
|
14
14
|
|
15
15
|
def self.run(params)
|
16
16
|
UI.message("The airwatch_workspaceone plugin is working!")
|
@@ -19,27 +19,26 @@ module Fastlane
|
|
19
19
|
$is_debug = params[:debug]
|
20
20
|
|
21
21
|
if debug
|
22
|
-
UI.message("
|
23
|
-
UI.message("
|
24
|
-
UI.message("
|
22
|
+
UI.message("-----------------------------------")
|
23
|
+
UI.message("DeployBuildAction debug information")
|
24
|
+
UI.message("-----------------------------------")
|
25
25
|
UI.message(" host_url: #{params[:host_url]}")
|
26
26
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
27
27
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
28
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
28
29
|
UI.message(" app_name: #{params[:app_name]}")
|
29
30
|
UI.message(" file_name: #{params[:file_name]}")
|
30
31
|
UI.message(" path_to_file: #{params[:path_to_file]}")
|
31
|
-
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
32
32
|
UI.message(" push_mode: #{params[:push_mode]}")
|
33
|
-
UI.message("---------------------------------")
|
34
33
|
end
|
35
34
|
|
36
|
-
host_url
|
37
|
-
aw_tenant_code
|
38
|
-
b64_encoded_auth
|
35
|
+
$host_url = params[:host_url]
|
36
|
+
$aw_tenant_code = params[:aw_tenant_code]
|
37
|
+
$b64_encoded_auth = params[:b64_encoded_auth]
|
38
|
+
$org_group_id = params[:org_group_id]
|
39
39
|
app_name = params[:app_name]
|
40
40
|
file_name = params[:file_name]
|
41
41
|
path_to_file = params[:path_to_file]
|
42
|
-
org_group_id = params[:org_group_id]
|
43
42
|
push_mode = params[:push_mode]
|
44
43
|
|
45
44
|
# step 1: determining device type
|
@@ -54,7 +53,7 @@ module Fastlane
|
|
54
53
|
UI.message("2. Setting supported device models")
|
55
54
|
UI.message("----------------------------------")
|
56
55
|
$supported_device_models = find_supported_device_models(path_to_file)
|
57
|
-
UI.success("Supported Device
|
56
|
+
UI.success("Supported Device Model(s): %s" % [$supported_device_models.to_json])
|
58
57
|
|
59
58
|
# step 3: uploading app blob file
|
60
59
|
UI.message("---------------------")
|
@@ -64,7 +63,7 @@ module Fastlane
|
|
64
63
|
UI.message("3. Uploading IPA file")
|
65
64
|
end
|
66
65
|
UI.message("---------------------")
|
67
|
-
blobID = upload_blob(
|
66
|
+
blobID = upload_blob(file_name, path_to_file)
|
68
67
|
|
69
68
|
if $device_type == "Android"
|
70
69
|
UI.success("Successfully uploaded apk blob")
|
@@ -80,7 +79,7 @@ module Fastlane
|
|
80
79
|
UI.message("------------------------------------")
|
81
80
|
UI.message("4. Deploying app version on console")
|
82
81
|
UI.message("------------------------------------")
|
83
|
-
deploy_app(
|
82
|
+
deploy_app(blobID, app_name, push_mode)
|
84
83
|
UI.success("Successfully deployed the app version")
|
85
84
|
end
|
86
85
|
|
@@ -134,21 +133,21 @@ module Fastlane
|
|
134
133
|
return model_hash
|
135
134
|
end
|
136
135
|
|
137
|
-
def self.upload_blob(
|
136
|
+
def self.upload_blob(file_name, path_to_file)
|
138
137
|
require 'rest-client'
|
139
138
|
require 'json'
|
140
139
|
|
141
140
|
response = RestClient::Request.execute(
|
142
|
-
:url
|
143
|
-
:method
|
144
|
-
:headers
|
145
|
-
'Authorization'
|
146
|
-
'aw-tenant-code'
|
147
|
-
'Accept'
|
148
|
-
'Content-Type'
|
149
|
-
'Expect'
|
141
|
+
:url => $host_url + UPLOAD_BLOB_SUFFIX % [file_name, $org_group_id],
|
142
|
+
:method => :post,
|
143
|
+
:headers => {
|
144
|
+
'Authorization' => "Basic " + $b64_encoded_auth,
|
145
|
+
'aw-tenant-code' => $aw_tenant_code,
|
146
|
+
'Accept' => 'application/json',
|
147
|
+
'Content-Type' => 'application/octet-stream',
|
148
|
+
'Expect' => '100-continue'
|
150
149
|
},
|
151
|
-
:payload
|
150
|
+
:payload => File.open(path_to_file, "rb")
|
152
151
|
)
|
153
152
|
|
154
153
|
if debug
|
@@ -161,17 +160,17 @@ module Fastlane
|
|
161
160
|
return json['Value']
|
162
161
|
end
|
163
162
|
|
164
|
-
def self.deploy_app(
|
163
|
+
def self.deploy_app(blobID, app_name, push_mode)
|
165
164
|
require 'rest-client'
|
166
165
|
require 'json'
|
167
166
|
|
168
167
|
body = {
|
169
|
-
"BlobId"
|
170
|
-
"DeviceType"
|
168
|
+
"BlobId" => blobID.to_s,
|
169
|
+
"DeviceType" => $device_type,
|
171
170
|
"ApplicationName" => app_name,
|
172
171
|
"SupportedModels" => $supported_device_models,
|
173
|
-
"PushMode"
|
174
|
-
"LocationGroupId" => org_group_id
|
172
|
+
"PushMode" => push_mode,
|
173
|
+
"LocationGroupId" => $org_group_id
|
175
174
|
}
|
176
175
|
|
177
176
|
if debug
|
@@ -179,7 +178,7 @@ module Fastlane
|
|
179
178
|
UI.message(body.to_json)
|
180
179
|
end
|
181
180
|
|
182
|
-
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})
|
181
|
+
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})
|
183
182
|
|
184
183
|
if debug
|
185
184
|
UI.message("Response code: %d" % [response.code])
|
@@ -205,7 +204,7 @@ module Fastlane
|
|
205
204
|
|
206
205
|
def self.details
|
207
206
|
# Optional:
|
208
|
-
"
|
207
|
+
"deploy_build - To upload an iOS ipa OR Android APK to AirWatch/WorkspaceOne console."
|
209
208
|
end
|
210
209
|
|
211
210
|
def self.available_options
|
@@ -237,6 +236,15 @@ module Fastlane
|
|
237
236
|
UI.user_error!("The authorization header is empty or the scheme is not basic") unless value and !value.empty?
|
238
237
|
end),
|
239
238
|
|
239
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
240
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
241
|
+
description: "Organization Group ID integer identifying the customer or container",
|
242
|
+
optional: false,
|
243
|
+
type: String,
|
244
|
+
verify_block: proc do |value|
|
245
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: MyOrgGroupId`") unless value and !value.empty?
|
246
|
+
end),
|
247
|
+
|
240
248
|
FastlaneCore::ConfigItem.new(key: :app_name,
|
241
249
|
env_name: "AIRWATCH_APPLICATION_NAME",
|
242
250
|
description: "Name of the application",
|
@@ -264,15 +272,6 @@ module Fastlane
|
|
264
272
|
UI.user_error!("Path to the file not given, pass using `path_to_file: '/path/to/the/file/on/disk'`") unless value and !value.empty?
|
265
273
|
end),
|
266
274
|
|
267
|
-
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
268
|
-
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
269
|
-
description: "Organization Group ID integer identifying the customer or container",
|
270
|
-
optional: false,
|
271
|
-
type: String,
|
272
|
-
verify_block: proc do |value|
|
273
|
-
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: MyOrgGroupId`") unless value and !value.empty?
|
274
|
-
end),
|
275
|
-
|
276
275
|
FastlaneCore::ConfigItem.new(key: :push_mode,
|
277
276
|
env_name: "AIRWATCH_APP_PUSH_MODE",
|
278
277
|
description: "Push mode for the application",
|
@@ -5,8 +5,9 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class RetirePreviousVersionsAction < Action
|
7
7
|
|
8
|
-
|
9
|
-
INTERNAL_APP_RETIRE_SUFFIX
|
8
|
+
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?bundleid=%s"
|
9
|
+
INTERNAL_APP_RETIRE_SUFFIX = "/API/mam/apps/internal/%d/retire"
|
10
|
+
|
10
11
|
$is_debug = false
|
11
12
|
|
12
13
|
def self.run(params)
|
@@ -16,67 +17,72 @@ module Fastlane
|
|
16
17
|
$is_debug = params[:debug]
|
17
18
|
|
18
19
|
if debug
|
19
|
-
UI.message("
|
20
|
-
UI.message("
|
21
|
-
UI.message("
|
20
|
+
UI.message("----------------------------------------------")
|
21
|
+
UI.message("RetirePreviousVersionsAction debug information")
|
22
|
+
UI.message("----------------------------------------------")
|
22
23
|
UI.message(" host_url: #{params[:host_url]}")
|
23
24
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
24
25
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
25
26
|
UI.message(" app_identifier: #{params[:app_identifier]}")
|
26
|
-
UI.message("
|
27
|
-
UI.message("---------------------------------")
|
27
|
+
UI.message(" keep_latest_versions_count: #{params[:keep_latest_versions_count]}")
|
28
28
|
end
|
29
29
|
|
30
|
-
host_url
|
31
|
-
aw_tenant_code
|
32
|
-
b64_encoded_auth
|
33
|
-
app_identifier
|
34
|
-
|
30
|
+
$host_url = params[:host_url]
|
31
|
+
$aw_tenant_code = params[:aw_tenant_code]
|
32
|
+
$b64_encoded_auth = params[:b64_encoded_auth]
|
33
|
+
app_identifier = params[:app_identifier]
|
34
|
+
keep_latest_versions_count = params[:keep_latest_versions_count]
|
35
35
|
|
36
36
|
# step 1: find app
|
37
37
|
UI.message("------------------------------")
|
38
38
|
UI.message("1. Finding active app versions")
|
39
39
|
UI.message("------------------------------")
|
40
40
|
|
41
|
-
|
42
|
-
UI.success("Found %d active app
|
43
|
-
|
44
|
-
UI.success("Integer app ids:")
|
45
|
-
UI.success(appIDs)
|
46
|
-
end
|
41
|
+
app_versions = find_app(app_identifier)
|
42
|
+
UI.success("Found %d active app version(s)" % [app_versions.count])
|
43
|
+
UI.success("Version number(s): %s" % [app_versions.map {|app_version| app_version.values[1]}])
|
47
44
|
|
48
45
|
# step 2: retire previous versions
|
49
|
-
UI.message("
|
50
|
-
UI.message("2. Retiring active app versions")
|
51
|
-
UI.message("
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
UI.message("-----------------------------------------")
|
47
|
+
UI.message("2. Retiring requested active app versions")
|
48
|
+
UI.message("-----------------------------------------")
|
49
|
+
|
50
|
+
keep_latest_versions_count_int = keep_latest_versions_count.to_i
|
51
|
+
if app_versions.count < keep_latest_versions_count_int
|
52
|
+
UI.important("Given number of latest versions to keep is greater than available number of versions on the store.")
|
53
|
+
UI.important("Will not retire any version.")
|
54
|
+
else
|
55
|
+
app_versions.pop(keep_latest_versions_count_int)
|
56
|
+
UI.important("Version number(s) to retire: %s" % [app_versions.map {|app_version| app_version.values[1]}])
|
57
|
+
app_versions.each do |app_version|
|
58
|
+
retire_app(app_version)
|
59
|
+
end
|
60
|
+
UI.success("Version(s) %s successfully retired." % [app_versions.map {|app_version| app_version.values[1]}])
|
55
61
|
end
|
56
|
-
|
57
|
-
UI.success("All active app versions successfully retired")
|
58
62
|
end
|
59
63
|
|
60
|
-
def self.find_app(app_identifier
|
64
|
+
def self.find_app(app_identifier)
|
61
65
|
# get the list of apps
|
62
|
-
data =
|
63
|
-
|
66
|
+
data = list_app_versions(app_identifier)
|
67
|
+
active_app_versions = Array.new
|
64
68
|
|
65
69
|
data['Application'].each do |app|
|
66
70
|
if app['Status'] == "Active"
|
67
|
-
|
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
|
68
75
|
end
|
69
76
|
end
|
70
77
|
|
71
|
-
|
72
|
-
return active_app_version_ids
|
78
|
+
return active_app_versions
|
73
79
|
end
|
74
80
|
|
75
|
-
def self.
|
81
|
+
def self.list_app_versions(app_identifier)
|
76
82
|
require 'rest-client'
|
77
83
|
require 'json'
|
78
84
|
|
79
|
-
response = RestClient.get(host_url +
|
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})
|
80
86
|
|
81
87
|
if debug
|
82
88
|
UI.message("Response code: %d" % [response.code])
|
@@ -84,35 +90,40 @@ module Fastlane
|
|
84
90
|
UI.message(response.body)
|
85
91
|
end
|
86
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
|
+
|
87
98
|
json = JSON.parse(response.body)
|
88
99
|
return json
|
89
100
|
end
|
90
101
|
|
91
|
-
def self.retire_app(
|
102
|
+
def self.retire_app(app_version)
|
92
103
|
require 'rest-client'
|
93
104
|
require 'json'
|
94
105
|
|
95
106
|
body = {
|
96
|
-
"applicationid" =>
|
107
|
+
"applicationid" => app_version['Id']
|
97
108
|
}
|
98
109
|
|
99
|
-
UI.message("Starting to retire app version
|
100
|
-
response = RestClient.post(host_url + INTERNAL_APP_RETIRE_SUFFIX % [
|
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})
|
101
112
|
|
102
113
|
if debug
|
103
114
|
UI.message("Response code: %d" % [response.code])
|
104
115
|
end
|
105
116
|
|
106
117
|
if response.code == 202
|
107
|
-
UI.message("Successfully retired app version
|
118
|
+
UI.message("Successfully retired app version: %s" % [app_version['Version']])
|
108
119
|
else
|
109
120
|
json = JSON.parse(response.body)
|
110
|
-
UI.message("Failed to retire app version
|
121
|
+
UI.message("Failed to retire app version: %s" % [app_version['Version']])
|
111
122
|
end
|
112
123
|
end
|
113
124
|
|
114
125
|
def self.description
|
115
|
-
"The main purpose of this action is to retire previous versions of the
|
126
|
+
"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."
|
116
127
|
end
|
117
128
|
|
118
129
|
def self.authors
|
@@ -125,7 +136,7 @@ module Fastlane
|
|
125
136
|
|
126
137
|
def self.details
|
127
138
|
# Optional:
|
128
|
-
"retire_previous_versions - To retire
|
139
|
+
"retire_previous_versions - To retire previous active versions of an application on the AirWatch console except the latest version."
|
129
140
|
end
|
130
141
|
|
131
142
|
def self.available_options
|
@@ -166,13 +177,14 @@ module Fastlane
|
|
166
177
|
UI.user_error!("No app identifier given, pass using `app_identifier: 'com.example.app'`") unless value and !value.empty?
|
167
178
|
end),
|
168
179
|
|
169
|
-
FastlaneCore::ConfigItem.new(key: :
|
170
|
-
env_name: "
|
171
|
-
description: "Name of the application",
|
172
|
-
optional:
|
180
|
+
FastlaneCore::ConfigItem.new(key: :keep_latest_versions_count,
|
181
|
+
env_name: "AIRWATCH_KEEP_LATEST_VERSIONS_COUNT",
|
182
|
+
description: "Name of the application. default: 1",
|
183
|
+
optional: true,
|
173
184
|
type: String,
|
185
|
+
default_value: "1",
|
174
186
|
verify_block: proc do |value|
|
175
|
-
UI.user_error!("
|
187
|
+
UI.user_error!("The number of latest versions to keep can not be zero or negative") unless value.to_i > 0
|
176
188
|
end),
|
177
189
|
|
178
190
|
FastlaneCore::ConfigItem.new(key: :debug,
|
@@ -200,4 +212,4 @@ module Fastlane
|
|
200
212
|
|
201
213
|
end
|
202
214
|
end
|
203
|
-
end
|
215
|
+
end
|