fastlane-plugin-airwatch_workspaceone 1.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +65 -0
- data/lib/fastlane/plugin/airwatch_workspaceone.rb +16 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/deploy_build_action.rb +310 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/retire_previous_versions_action.rb +203 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/helper/airwatch_workspaceone_helper.rb +16 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/version.rb +5 -0
- metadata +204 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 39315e767417928a349b1bba6a2bcac2d42f935e027753d986771b446ad9656e
|
4
|
+
data.tar.gz: c5ab5f15c2cb9e61035c28871363dca9973ca3b5a8c255199a9af0de1aed056a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21276710b52ada59e01df121a21e1ecb578aca7928591be865dce2dd097957d6bd662cee3fd78a1199aeb2c609f3b1cdeb22ee633a478cb0d174da6b3787f45a
|
7
|
+
data.tar.gz: af153dcce9a53d8a05530f920facf992699f2556f9decc6bcbb5a45b42c7bec4c02ec4e821b2d510878a25457db86855e2dc1f9c22a3bb2f067b77f392d672e4
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 sharar <ram.awadhesh1.618@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# airwatch_workspaceone plugin
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/fastlane-plugin-airwatch_workspaceone)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-airwatch_workspaceone`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin airwatch_workspaceone
|
11
|
+
```
|
12
|
+
|
13
|
+
## About airwatch_workspaceone
|
14
|
+
|
15
|
+
The main purpose of this plugin is to upload an IPA or an APK file to an AirWatch or Workspace ONE enterprise instance/console.
|
16
|
+
|
17
|
+
This plugin features two actions :-
|
18
|
+
1. deploy_build - To upload an iOS ipa OR Android APK to AirWatch/WorkspaceOne console.
|
19
|
+
2. retire_previous_versions - To retire all active versions of the application on the AirWatch console except the latest version.
|
20
|
+
|
21
|
+
## Available options
|
22
|
+
|
23
|
+
To check for available options, run
|
24
|
+
|
25
|
+
```bash
|
26
|
+
fastlane action deploy_app
|
27
|
+
```
|
28
|
+
and
|
29
|
+
|
30
|
+
```bash
|
31
|
+
fastlane action retire_previous_versions
|
32
|
+
```
|
33
|
+
|
34
|
+
## Example
|
35
|
+
|
36
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin.
|
37
|
+
|
38
|
+
## Run tests for this plugin
|
39
|
+
|
40
|
+
To run both the tests, and code style validation, run
|
41
|
+
|
42
|
+
```
|
43
|
+
rake
|
44
|
+
```
|
45
|
+
|
46
|
+
To automatically fix many of the styling issues, use
|
47
|
+
```
|
48
|
+
rubocop -a
|
49
|
+
```
|
50
|
+
|
51
|
+
## Issues and Feedback
|
52
|
+
|
53
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
54
|
+
|
55
|
+
## Troubleshooting
|
56
|
+
|
57
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
58
|
+
|
59
|
+
## Using _fastlane_ Plugins
|
60
|
+
|
61
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
62
|
+
|
63
|
+
## About _fastlane_
|
64
|
+
|
65
|
+
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/airwatch_workspaceone/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module AirwatchWorkspaceone
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::AirwatchWorkspaceone.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
@@ -0,0 +1,310 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/airwatch_workspaceone_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class DeployBuildAction < Action
|
7
|
+
|
8
|
+
UPLOAD_BLOB_SUFFIX = "/API/mam/blobs/uploadblob?fileName=%s&organizationGroupId=%s"
|
9
|
+
BEGIN_INSTALL_SUFFIX = "/API/mam/apps/internal/begininstall"
|
10
|
+
|
11
|
+
$is_debug = false
|
12
|
+
$device_type = "Apple"
|
13
|
+
$supported_device_models = Hash.new
|
14
|
+
|
15
|
+
def self.run(params)
|
16
|
+
UI.message("The airwatch_workspaceone plugin is working!")
|
17
|
+
|
18
|
+
# check if debug is enabled
|
19
|
+
$is_debug = params[:debug]
|
20
|
+
|
21
|
+
if debug
|
22
|
+
UI.message("---------------------------------")
|
23
|
+
UI.message("AirWatch plugin debug information")
|
24
|
+
UI.message("---------------------------------")
|
25
|
+
UI.message(" host_url: #{params[:host_url]}")
|
26
|
+
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
27
|
+
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
28
|
+
UI.message(" app_name: #{params[:app_name]}")
|
29
|
+
UI.message(" file_name: #{params[:file_name]}")
|
30
|
+
UI.message(" path_to_file: #{params[:path_to_file]}")
|
31
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
32
|
+
UI.message(" push_mode: #{params[:push_mode]}")
|
33
|
+
UI.message("---------------------------------")
|
34
|
+
end
|
35
|
+
|
36
|
+
host_url = params[:host_url]
|
37
|
+
aw_tenant_code = params[:aw_tenant_code]
|
38
|
+
b64_encoded_auth = params[:b64_encoded_auth]
|
39
|
+
app_name = params[:app_name]
|
40
|
+
file_name = params[:file_name]
|
41
|
+
path_to_file = params[:path_to_file]
|
42
|
+
org_group_id = params[:org_group_id]
|
43
|
+
push_mode = params[:push_mode]
|
44
|
+
|
45
|
+
# step 1: determining device type
|
46
|
+
UI.message("----------------------")
|
47
|
+
UI.message("1. Finding device type")
|
48
|
+
UI.message("----------------------")
|
49
|
+
$device_type = find_device_type(file_name)
|
50
|
+
UI.success("Device Type identified is: %s" % [$device_type])
|
51
|
+
|
52
|
+
# step 2: determining device type
|
53
|
+
UI.message("----------------------------------")
|
54
|
+
UI.message("2. Setting supported device models")
|
55
|
+
UI.message("----------------------------------")
|
56
|
+
$supported_device_models = find_supported_device_models(path_to_file)
|
57
|
+
UI.success("Supported Device Models are: %s" % [$supported_device_models.to_json])
|
58
|
+
|
59
|
+
# step 3: uploading app blob file
|
60
|
+
UI.message("---------------------")
|
61
|
+
if $device_type == "Android"
|
62
|
+
UI.message("3. Uploading APK file")
|
63
|
+
else
|
64
|
+
UI.message("3. Uploading IPA file")
|
65
|
+
end
|
66
|
+
UI.message("---------------------")
|
67
|
+
blobID = upload_blob(host_url, aw_tenant_code, b64_encoded_auth, file_name, path_to_file, org_group_id)
|
68
|
+
|
69
|
+
if $device_type == "Android"
|
70
|
+
UI.success("Successfully uploaded apk blob")
|
71
|
+
else
|
72
|
+
UI.success("Successfully uploaded ipa blob")
|
73
|
+
end
|
74
|
+
|
75
|
+
if debug
|
76
|
+
UI.success("Blob Id: %d" % [blobID])
|
77
|
+
end
|
78
|
+
|
79
|
+
# step 4: deploying app version
|
80
|
+
UI.message("------------------------------------")
|
81
|
+
UI.message("4. Deploying app version on console")
|
82
|
+
UI.message("------------------------------------")
|
83
|
+
deploy_app(host_url, aw_tenant_code, b64_encoded_auth, blobID, app_name, push_mode, org_group_id)
|
84
|
+
UI.success("Successfully deployed the app version")
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.find_device_type(file_name)
|
88
|
+
if file_name.include? ".ipa"
|
89
|
+
return "Apple"
|
90
|
+
elsif file_name.include? ".apk"
|
91
|
+
return "Android"
|
92
|
+
else
|
93
|
+
UI.user_error!("Wrong file type provided. Please provide an IPA or APK file.")
|
94
|
+
exit
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.find_supported_device_models(path_to_file)
|
99
|
+
require 'app_info'
|
100
|
+
device_models = Array.new
|
101
|
+
|
102
|
+
if $device_type == "Android"
|
103
|
+
model = create_model_for(5, "Android")
|
104
|
+
device_models << model
|
105
|
+
else
|
106
|
+
ipa = AppInfo.parse(path_to_file)
|
107
|
+
if ipa.universal?
|
108
|
+
model_iPhone = create_model_for(1, "iPhone")
|
109
|
+
device_models << model_iPhone
|
110
|
+
model_iPad = create_model_for(2, "iPad")
|
111
|
+
device_models << model_iPad
|
112
|
+
model_iPodTouch = create_model_for(3, "iPod Touch")
|
113
|
+
device_models << model_iPodTouch
|
114
|
+
elsif ipa.iphone?
|
115
|
+
model_iPhone = create_model_for(1, "iPhone")
|
116
|
+
device_models << model_iPhone
|
117
|
+
model_iPodTouch = create_model_for(3, "iPod Touch")
|
118
|
+
device_models << model_iPodTouch
|
119
|
+
else
|
120
|
+
model_iPad = create_model_for(2, "iPad")
|
121
|
+
device_models << model_iPad
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
$supported_device_models['Model'] = device_models
|
126
|
+
return $supported_device_models
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.create_model_for(model_id, model_name)
|
130
|
+
|
131
|
+
model_hash = Hash.new
|
132
|
+
model_hash['ModelId'] = model_id
|
133
|
+
model_hash['ModelName'] = model_name
|
134
|
+
return model_hash
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.upload_blob(host_url, aw_tenant_code, b64_encoded_auth, file_name, path_to_file, org_group_id)
|
138
|
+
require 'rest-client'
|
139
|
+
require 'json'
|
140
|
+
|
141
|
+
response = RestClient::Request.execute(
|
142
|
+
:url => host_url + UPLOAD_BLOB_SUFFIX % [file_name, org_group_id],
|
143
|
+
:method => :post,
|
144
|
+
:headers => {
|
145
|
+
'Authorization' => "Basic " + b64_encoded_auth,
|
146
|
+
'aw-tenant-code' => aw_tenant_code,
|
147
|
+
'Accept' => 'application/json',
|
148
|
+
'Content-Type' => 'application/octet-stream',
|
149
|
+
'Expect' => '100-continue'
|
150
|
+
},
|
151
|
+
:payload => File.open(path_to_file, "rb")
|
152
|
+
)
|
153
|
+
|
154
|
+
if debug
|
155
|
+
UI.message("Response code: %d" % [response.code])
|
156
|
+
UI.message("Response body:")
|
157
|
+
UI.message(response.body)
|
158
|
+
end
|
159
|
+
|
160
|
+
json = JSON.parse(response.body)
|
161
|
+
return json['Value']
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.deploy_app(host_url, aw_tenant_code, b64_encoded_auth, blobID, app_name, push_mode, org_group_id)
|
165
|
+
require 'rest-client'
|
166
|
+
require 'json'
|
167
|
+
|
168
|
+
body = {
|
169
|
+
"BlobId" => blobID.to_s,
|
170
|
+
"DeviceType" => $device_type,
|
171
|
+
"ApplicationName" => app_name,
|
172
|
+
"SupportedModels" => $supported_device_models,
|
173
|
+
"PushMode" => push_mode,
|
174
|
+
"LocationGroupId" => org_group_id
|
175
|
+
}
|
176
|
+
|
177
|
+
if debug
|
178
|
+
UI.message("Deploy Request JSON:")
|
179
|
+
UI.message(body.to_json)
|
180
|
+
end
|
181
|
+
|
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})
|
183
|
+
|
184
|
+
if debug
|
185
|
+
UI.message("Response code: %d" % [response.code])
|
186
|
+
UI.message("Response body:")
|
187
|
+
UI.message(response.body)
|
188
|
+
end
|
189
|
+
|
190
|
+
json = JSON.parse(response.body)
|
191
|
+
return json
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.description
|
195
|
+
"The main purpose of this action is to upload an IPA or an APK file to an AirWatch or Workspace ONE enterprise instance/console."
|
196
|
+
end
|
197
|
+
|
198
|
+
def self.authors
|
199
|
+
["Ram Awadhesh Sharan"]
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.return_value
|
203
|
+
# If your method provides a return value, you can describe here what it does
|
204
|
+
end
|
205
|
+
|
206
|
+
def self.details
|
207
|
+
# Optional:
|
208
|
+
"deploy_app - To upload an iOS ipa OR Android APK to AirWatch/WorkspaceOne console."
|
209
|
+
end
|
210
|
+
|
211
|
+
def self.available_options
|
212
|
+
[
|
213
|
+
FastlaneCore::ConfigItem.new(key: :host_url,
|
214
|
+
env_name: "AIRWATCH_HOST_API_URL",
|
215
|
+
description: "Host API URL of the AirWatch instance",
|
216
|
+
optional: false,
|
217
|
+
type: String,
|
218
|
+
verify_block: proc do |value|
|
219
|
+
UI.user_error!("No AirWatch Host API URl given.") unless value and !value.empty?
|
220
|
+
end),
|
221
|
+
|
222
|
+
FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
|
223
|
+
env_name: "AIRWATCH_API_KEY",
|
224
|
+
description: "API key or the tenant code to access AirWatch Rest APIs",
|
225
|
+
optional: false,
|
226
|
+
type: String,
|
227
|
+
verify_block: proc do |value|
|
228
|
+
UI.user_error!("Api tenant code header is missing.") unless value and !value.empty?
|
229
|
+
end),
|
230
|
+
|
231
|
+
FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
|
232
|
+
env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
|
233
|
+
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch instance",
|
234
|
+
optional: false,
|
235
|
+
type: String,
|
236
|
+
verify_block: proc do |value|
|
237
|
+
UI.user_error!("The authorization header is empty or the scheme is not basic") unless value and !value.empty?
|
238
|
+
end),
|
239
|
+
|
240
|
+
FastlaneCore::ConfigItem.new(key: :app_name,
|
241
|
+
env_name: "AIRWATCH_APPLICATION_NAME",
|
242
|
+
description: "Name of the application",
|
243
|
+
optional: false,
|
244
|
+
type: String,
|
245
|
+
verify_block: proc do |value|
|
246
|
+
UI.user_error!("No app name given, pass using `app_name: 'My sample app'`") unless value and !value.empty?
|
247
|
+
end),
|
248
|
+
|
249
|
+
FastlaneCore::ConfigItem.new(key: :file_name,
|
250
|
+
env_name: "AIRWATCH_FILE_NAME",
|
251
|
+
description: "Name of the file to upload including the extension",
|
252
|
+
optional: false,
|
253
|
+
type: String,
|
254
|
+
verify_block: proc do |value|
|
255
|
+
UI.user_error!("No file name given, pass using `file_name: 'MySampleApp.ipa'` or `file_name: 'MySampleApp.apk'`") unless value and !value.empty?
|
256
|
+
end),
|
257
|
+
|
258
|
+
FastlaneCore::ConfigItem.new(key: :path_to_file,
|
259
|
+
env_name: "AIRWATCH_PATH_TO_FILE",
|
260
|
+
description: "Path to the file to upload including the extension",
|
261
|
+
optional: false,
|
262
|
+
type: String,
|
263
|
+
verify_block: proc do |value|
|
264
|
+
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
|
+
end),
|
266
|
+
|
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
|
+
FastlaneCore::ConfigItem.new(key: :push_mode,
|
277
|
+
env_name: "AIRWATCH_APP_PUSH_MODE",
|
278
|
+
description: "Push mode for the application",
|
279
|
+
optional: false,
|
280
|
+
type: String,
|
281
|
+
verify_block: proc do |value|
|
282
|
+
UI.user_error!("No push mode given, pass using `push_mode: 'Auto'` or pass using `push_mode: 'On demand'`") unless value and !value.empty?
|
283
|
+
end),
|
284
|
+
|
285
|
+
FastlaneCore::ConfigItem.new(key: :debug,
|
286
|
+
env_name: "AIRWATCH_DEBUG",
|
287
|
+
description: "Debug flag, set to true to show extended output. default: false",
|
288
|
+
optional: true,
|
289
|
+
is_string: false,
|
290
|
+
default_value: false)
|
291
|
+
]
|
292
|
+
end
|
293
|
+
|
294
|
+
def self.is_supported?(platform)
|
295
|
+
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
296
|
+
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
297
|
+
#
|
298
|
+
[:ios, :android].include?(platform)
|
299
|
+
true
|
300
|
+
end
|
301
|
+
|
302
|
+
# helpers
|
303
|
+
|
304
|
+
def self.debug
|
305
|
+
$is_debug
|
306
|
+
end
|
307
|
+
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/airwatchtest_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class RetirePreviousVersionsAction < Action
|
7
|
+
|
8
|
+
APPS_LIST_SUFFIX = "/API/mam/apps/search?bundleid=%s"
|
9
|
+
INTERNAL_APP_RETIRE_SUFFIX = "/API/mam/apps/internal/%d/retire"
|
10
|
+
$is_debug = false
|
11
|
+
|
12
|
+
def self.run(params)
|
13
|
+
UI.message("The airwatch_workspaceone plugin is working!")
|
14
|
+
|
15
|
+
# check if debug is enabled
|
16
|
+
$is_debug = params[:debug]
|
17
|
+
|
18
|
+
if debug
|
19
|
+
UI.message("---------------------------------")
|
20
|
+
UI.message("AirWatch plugin debug information")
|
21
|
+
UI.message("---------------------------------")
|
22
|
+
UI.message(" host_url: #{params[:host_url]}")
|
23
|
+
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
24
|
+
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
25
|
+
UI.message(" app_identifier: #{params[:app_identifier]}")
|
26
|
+
UI.message(" app_name: #{params[:app_name]}")
|
27
|
+
UI.message("---------------------------------")
|
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
|
+
app_name = params[:app_name]
|
35
|
+
|
36
|
+
# step 1: find app
|
37
|
+
UI.message("------------------------------")
|
38
|
+
UI.message("1. Finding active app versions")
|
39
|
+
UI.message("------------------------------")
|
40
|
+
|
41
|
+
appIDs = find_app(app_identifier, host_url, aw_tenant_code, b64_encoded_auth)
|
42
|
+
UI.success("Found %d active app versions" % [appIDs.count])
|
43
|
+
if debug
|
44
|
+
UI.success("Integer app ids:")
|
45
|
+
UI.success(appIDs)
|
46
|
+
end
|
47
|
+
|
48
|
+
# step 2: retire previous versions
|
49
|
+
UI.message("-------------------------------")
|
50
|
+
UI.message("2. Retiring active app versions")
|
51
|
+
UI.message("-------------------------------")
|
52
|
+
|
53
|
+
appIDs.each do |appID|
|
54
|
+
retire_app(host_url, aw_tenant_code, b64_encoded_auth, appID)
|
55
|
+
end
|
56
|
+
|
57
|
+
UI.success("All active app versions successfully retired")
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.find_app(app_identifier, host_url, aw_tenant_code, b64_encoded_auth)
|
61
|
+
# get the list of apps
|
62
|
+
data = list_apps(host_url, aw_tenant_code, b64_encoded_auth, app_identifier)
|
63
|
+
active_app_version_ids = Array.new
|
64
|
+
|
65
|
+
data['Application'].each do |app|
|
66
|
+
if app['Status'] == "Active"
|
67
|
+
active_app_version_ids << app['Id']['Value']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
active_app_version_ids.pop
|
72
|
+
return active_app_version_ids
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.list_apps(host_url, aw_tenant_code, b64_encoded_auth, app_identifier)
|
76
|
+
require 'rest-client'
|
77
|
+
require 'json'
|
78
|
+
|
79
|
+
response = RestClient.get(host_url + APPS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': aw_tenant_code, 'Authorization': "Basic " + b64_encoded_auth})
|
80
|
+
|
81
|
+
if debug
|
82
|
+
UI.message("Response code: %d" % [response.code])
|
83
|
+
UI.message("Response body:")
|
84
|
+
UI.message(response.body)
|
85
|
+
end
|
86
|
+
|
87
|
+
json = JSON.parse(response.body)
|
88
|
+
return json
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.retire_app(host_url, aw_tenant_code, b64_encoded_auth, app_id)
|
92
|
+
require 'rest-client'
|
93
|
+
require 'json'
|
94
|
+
|
95
|
+
body = {
|
96
|
+
"applicationid" => app_id
|
97
|
+
}
|
98
|
+
|
99
|
+
UI.message("Starting to retire app version having integer identifier: %d" % [app_id])
|
100
|
+
response = RestClient.post(host_url + INTERNAL_APP_RETIRE_SUFFIX % [app_id], body.to_json, {accept: :json, 'aw-tenant-code': aw_tenant_code, 'Authorization': "Basic " + b64_encoded_auth})
|
101
|
+
|
102
|
+
if debug
|
103
|
+
UI.message("Response code: %d" % [response.code])
|
104
|
+
end
|
105
|
+
|
106
|
+
if response.code == 202
|
107
|
+
UI.message("Successfully retired app version having integer identifier: %d" % [app_id])
|
108
|
+
else
|
109
|
+
json = JSON.parse(response.body)
|
110
|
+
UI.message("Failed to retire app version having integer identifier: %d" % [app_id])
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.description
|
115
|
+
"The main purpose of this action is to retire previous versions of the application"
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.authors
|
119
|
+
["Ram Awadhesh Sharan"]
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.return_value
|
123
|
+
# If your method provides a return value, you can describe here what it does
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.details
|
127
|
+
# Optional:
|
128
|
+
"retire_previous_versions - To retire all active versions of the application on the AirWatch console except the latest version."
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.available_options
|
132
|
+
[
|
133
|
+
FastlaneCore::ConfigItem.new(key: :host_url,
|
134
|
+
env_name: "AIRWATCH_HOST_API_URL",
|
135
|
+
description: "Host API URL of the AirWatch instance",
|
136
|
+
optional: false,
|
137
|
+
type: String,
|
138
|
+
verify_block: proc do |value|
|
139
|
+
UI.user_error!("No AirWatch Host API URl given.") unless value and !value.empty?
|
140
|
+
end),
|
141
|
+
|
142
|
+
FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
|
143
|
+
env_name: "AIRWATCH_API_KEY",
|
144
|
+
description: "API key to access AirWatch Rest APIs",
|
145
|
+
optional: false,
|
146
|
+
type: String,
|
147
|
+
verify_block: proc do |value|
|
148
|
+
UI.user_error!("Api tenant code header is missing.") unless value and !value.empty?
|
149
|
+
end),
|
150
|
+
|
151
|
+
FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
|
152
|
+
env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
|
153
|
+
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch instance",
|
154
|
+
optional: false,
|
155
|
+
type: String,
|
156
|
+
verify_block: proc do |value|
|
157
|
+
UI.user_error!("The authorization header is empty or the scheme is not basic") unless value and !value.empty?
|
158
|
+
end),
|
159
|
+
|
160
|
+
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
161
|
+
env_name: "APP_IDENTIFIER",
|
162
|
+
description: "Bundle identifier of your app",
|
163
|
+
optional: false,
|
164
|
+
type: String,
|
165
|
+
verify_block: proc do |value|
|
166
|
+
UI.user_error!("No app identifier given, pass using `app_identifier: 'com.example.app'`") unless value and !value.empty?
|
167
|
+
end),
|
168
|
+
|
169
|
+
FastlaneCore::ConfigItem.new(key: :app_name,
|
170
|
+
env_name: "AIRWATCH_APPLICATION_NAME",
|
171
|
+
description: "Name of the application",
|
172
|
+
optional: false,
|
173
|
+
type: String,
|
174
|
+
verify_block: proc do |value|
|
175
|
+
UI.user_error!("No app name given, pass using `app_name: 'My sample app'`") unless value and !value.empty?
|
176
|
+
end),
|
177
|
+
|
178
|
+
FastlaneCore::ConfigItem.new(key: :debug,
|
179
|
+
env_name: "AIRWATCH_DEBUG",
|
180
|
+
description: "Debug flag, set to true to show extended output. default: false",
|
181
|
+
optional: true,
|
182
|
+
is_string: false,
|
183
|
+
default_value: false)
|
184
|
+
]
|
185
|
+
end
|
186
|
+
|
187
|
+
def self.is_supported?(platform)
|
188
|
+
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
189
|
+
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
190
|
+
|
191
|
+
[:ios, :android].include?(platform)
|
192
|
+
true
|
193
|
+
end
|
194
|
+
|
195
|
+
# helpers
|
196
|
+
|
197
|
+
def self.debug
|
198
|
+
$is_debug
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
5
|
+
|
6
|
+
module Helper
|
7
|
+
class AirwatchWorkspaceoneHelper
|
8
|
+
# class methods that you define here become available in your action
|
9
|
+
# as `Helper::AirwatchWorkspaceoneHelper.your_method`
|
10
|
+
#
|
11
|
+
def self.show_message
|
12
|
+
UI.message("Hello from the airwatch_workspaceone plugin helper!")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-airwatch_workspaceone
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ram Awadhesh Sharan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: app-info
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec_junit_formatter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.49.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.49.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-require_tools
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: fastlane
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.123.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 2.123.0
|
167
|
+
description:
|
168
|
+
email: ram.awadhesh1.618@emc.com
|
169
|
+
executables: []
|
170
|
+
extensions: []
|
171
|
+
extra_rdoc_files: []
|
172
|
+
files:
|
173
|
+
- LICENSE
|
174
|
+
- README.md
|
175
|
+
- lib/fastlane/plugin/airwatch_workspaceone.rb
|
176
|
+
- lib/fastlane/plugin/airwatch_workspaceone/actions/deploy_build_action.rb
|
177
|
+
- lib/fastlane/plugin/airwatch_workspaceone/actions/retire_previous_versions_action.rb
|
178
|
+
- lib/fastlane/plugin/airwatch_workspaceone/helper/airwatch_workspaceone_helper.rb
|
179
|
+
- lib/fastlane/plugin/airwatch_workspaceone/version.rb
|
180
|
+
homepage: https://github.com/letsbondiway/fastlane-plugin-airwatch_workspaceone
|
181
|
+
licenses:
|
182
|
+
- MIT
|
183
|
+
metadata: {}
|
184
|
+
post_install_message:
|
185
|
+
rdoc_options: []
|
186
|
+
require_paths:
|
187
|
+
- lib
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
requirements: []
|
199
|
+
rubygems_version: 3.0.3
|
200
|
+
signing_key:
|
201
|
+
specification_version: 4
|
202
|
+
summary: The main purpose of this plugin is to upload an IPA or an APK file to an
|
203
|
+
AirWatch or Workspace ONE enterprise instance/console.
|
204
|
+
test_files: []
|