fastlane-plugin-appcircle_testing_distribution 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b64765e71d94a9c037ef58a5109980d9e3a1bce39a84d9d5842f211b97d0889e
4
- data.tar.gz: 6d0ed0450b800a318983f163321822e205da2fe6694f49733838e3c43ad3cb66
3
+ metadata.gz: a02bb68865ce3d94c903651486aa0da0dd6ce65b1a031d49f9ae65dd1f280df3
4
+ data.tar.gz: 7cf9e84c39f8dac3db289e273d15b4b458baf1a3c3c8307e1fa04ae483dcda07
5
5
  SHA512:
6
- metadata.gz: d74c3aa5d3f9cd80dba5aaa47c4b941e50c9ae7d9d7cac3158c6c44c8775b0f3a0f92f3bcf87229f079484b2d7540528e1944bcc19982bc456ae1012fead7103
7
- data.tar.gz: 5a0cf92d63c58ef0001b29dae6241dc4680235a7f059bb3e404f71aa164741a7ec30cc3a79f60ae18cb61c8f1f5c6388756997728750eed8511ddd5bd4c7cb3f
6
+ metadata.gz: 3c220a3b09805d02df2e3cab87bb4cb89714a00a27b598cfc83a51f61436b3ee84c709c4378effbf161fed1654b2fe2250dc95fcefff34a45c60896ed2a76c0e
7
+ data.tar.gz: 387fc503a7975c0f8fa3f021e4f5c466c79a8cdcc11b9c38669c932bfe7d96469bb53b6a8181c3fcb6059f160ade2612f306f74518ec407cf966dd938f814e97
data/README.md CHANGED
@@ -42,7 +42,7 @@ Overall, using testing distribution in mobile DevOps significantly enhances the
42
42
 
43
43
  In order to share your builds with testers, you can create distribution profiles and assign testing groups to the distribution profiles.
44
44
 
45
- ![Distribution Profile](images/distribution-start.png)
45
+ ![Distribution Profile](<https://cdn.appcircle.io/docs/assets/image%20(152).png>)
46
46
 
47
47
  ## Generating/Managing the Personal API Tokens
48
48
 
@@ -52,7 +52,7 @@ To generate a Personal API Token, follow these steps:
52
52
  2. You'll find the Personal API Token section in the top right corner.
53
53
  3. Press the "Generate Token" button to generate your first token.
54
54
 
55
- ![Token Generation](images/PAT.png)
55
+ ![Token Generation](<https://cdn.appcircle.io/docs/assets/image%20(164).png>)
56
56
 
57
57
  ## Getting Started with the Extension: Usage Guide
58
58
 
@@ -1,4 +1,7 @@
1
1
  require 'fastlane/action'
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'json'
2
5
  require_relative '../helper/appcircle_testing_distribution_helper'
3
6
 
4
7
  module Fastlane
@@ -10,9 +13,19 @@ module Fastlane
10
13
  appPath = params[:appPath]
11
14
  message = params[:message]
12
15
 
16
+ if accessToken.nil?
17
+ raise UI.error("Access token is required to authenticate connections to Appcircle services. Please provide a valid access token")
18
+ elsif profileID.nil?
19
+ raise UI.error("Distribution profile ID is required to distribute applications. Please provide a valid distribution profile ID")
20
+ elsif appPath.nil?
21
+ raise UI.error("Application file path is required to distribute applications. Please provide a valid application file path")
22
+ elsif message.nil?
23
+ raise UI.error("Message field is required. Please provide a valid message")
24
+ end
25
+
26
+
13
27
  self.ac_login(accessToken)
14
28
  self.ac_upload(appPath, profileID, message)
15
-
16
29
  end
17
30
 
18
31
  def self.ac_login(accessToken)
@@ -23,10 +36,48 @@ module Fastlane
23
36
  raise "Error executing command of logging to Appcircle. Please make sure you have installed Appcircle CLI and provided a valid access token. For more information, please visit https://docs.appcircle.io/appcircle-api/api-authentication#generatingmanaging-the-personal-api-tokens #{ac_login}"
24
37
  end
25
38
  end
39
+
40
+ def self.checkTaskStatus(taskId)
41
+ uri = URI.parse("https://api.appcircle.io/task/v1/tasks/#{taskId}")
42
+ timeout = 1
43
+ jwtToken = `appcircle config get AC_ACCESS_TOKEN -o json`
44
+ apiAccessToken = JSON.parse(jwtToken)
45
+
46
+ response = self.send_request(uri, apiAccessToken["AC_ACCESS_TOKEN"])
47
+ if response.is_a?(Net::HTTPSuccess)
48
+ stateValue = JSON.parse(response.body)["stateValue"]
49
+
50
+ if stateValue == 1
51
+ sleep(1)
52
+ return checkTaskStatus(taskId)
53
+ end
54
+ if stateValue == 3
55
+ return true
56
+ else
57
+ UI.error("Task Id #{taskId} failed with state value #{stateValue}")
58
+ raise "Upload could not completed successfully"
59
+ end
60
+ else
61
+ UI.error("Request failed with response code #{response.code} and message #{response.message}")
62
+ raise "Request failed"
63
+ end
64
+ end
65
+
66
+ def self.send_request(uri, access_token)
67
+ http = Net::HTTP.new(uri.host, uri.port)
68
+ http.use_ssl = (uri.scheme == "https")
69
+ request = Net::HTTP::Get.new(uri.request_uri)
70
+ request["Authorization"] = "Bearer #{access_token}"
71
+ http.request(request)
72
+ end
26
73
 
27
74
  def self.ac_upload(appPath, profileID, message)
28
- ac_upload = `appcircle testing-distribution upload --app=#{appPath} --distProfileId=#{profileID} --message "#{message}"`;
29
- if $?.success?
75
+ ac_upload = `appcircle testing-distribution upload --app=#{appPath} --distProfileId=#{profileID} --message "#{message}" -o json`
76
+ taskId = JSON.parse(ac_upload)["taskId"]
77
+ UI.message("taskID #{taskId}")
78
+ result = self.checkTaskStatus(taskId)
79
+
80
+ if $?.success? and result
30
81
  UI.success("#{appPath} Uploaded to Appcircle successfully.")
31
82
  else
32
83
  raise "Error executing command of uploading to Appcircle. Please make sure you have provide the valid app path and distribution profile id. For more information\n" + ac_upload
@@ -53,28 +104,28 @@ module Fastlane
53
104
  def self.available_options
54
105
  [
55
106
  FastlaneCore::ConfigItem.new(key: :accessToken,
56
- env_name: "AC_ACCESS_TOKEN",
57
- description: "Provide the Appcircle access token to authenticate connections to Appcircle services. This token allows your Azure DevOps pipeline to interact with Appcircle for distributing applications",
58
- optional: false,
59
- type: String),
107
+ env_name: "AC_ACCESS_TOKEN",
108
+ description: "Provide the Appcircle access token to authenticate connections to Appcircle services",
109
+ optional: false,
110
+ type: String),
60
111
 
61
112
  FastlaneCore::ConfigItem.new(key: :profileID,
62
- env_name: "AC_PROFILE_ID",
63
- description: "Enter the ID of the Appcircle distribution profile. This ID uniquely identifies the profile under which your applications will be distributed",
64
- optional: false,
65
- type: String),
113
+ env_name: "AC_PROFILE_ID",
114
+ description: "Enter the ID of the Appcircle distribution profile. This ID uniquely identifies the profile under which your applications will be distributed",
115
+ optional: false,
116
+ type: String),
66
117
 
67
118
  FastlaneCore::ConfigItem.new(key: :appPath,
68
- env_name: "AC_APP_PATH",
69
- description: "Specify the path to your application file. For iOS, this can be a .ipa or .xcarchive file path. For Android, specify the .apk or .appbundle file path",
70
- optional: false,
71
- type: String),
72
-
119
+ env_name: "AC_APP_PATH",
120
+ description: "Specify the path to your application file. For iOS, this can be a .ipa or .xcarchive file path. For Android, specify the .apk or .appbundle file path",
121
+ optional: false,
122
+ type: String),
123
+
73
124
  FastlaneCore::ConfigItem.new(key: :message,
74
- env_name: "AC_MESSAGE",
75
- description: "Optional message to include with the distribution to provide additional information to testers or users receiving the build",
76
- optional: false,
77
- type: String),
125
+ env_name: "AC_MESSAGE",
126
+ description: "Optional message to include with the distribution to provide additional information to testers or users receiving the build",
127
+ optional: false,
128
+ type: String)
78
129
  ]
79
130
  end
80
131
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AppcircleTestingDistribution
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-appcircle_testing_distribution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - appcircleio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-11 00:00:00.000000000 Z
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: cloud@appcircle.io