fastlane-plugin-bitrise_automation 0.2.0 → 0.4.1
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 +6 -2
- data/lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_status_action.rb +1 -0
- data/lib/fastlane/plugin/bitrise_automation/actions/trigger_bitrise_workflow_action.rb +30 -10
- data/lib/fastlane/plugin/bitrise_automation/helper/bitrise_automation_helper.rb +26 -2
- data/lib/fastlane/plugin/bitrise_automation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52d8e6af9f3d94409439d852326a6f3695bf4a5c79bc2ec1bb73697cb14f4bfb
|
4
|
+
data.tar.gz: a240c2baac03ac01441f88cd38d2939212d38e4c749ab177da22e3746b84ff76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfd962e3d6e904987bc0eda66f75bcb415a5f9995e16410837b9f243c9cef49955ac1851a716ecdd349d9d9273a62c68a212725153b969269fdd6e3e50c36116
|
7
|
+
data.tar.gz: 4ed1d1619b5ae73215de09258e8e0bf33e3f027bf6338426df82848f6673d28b777231ec2c5e67f5cb0db400f9895cf800082dc15879ea65445ea4225a73ea57
|
data/README.md
CHANGED
@@ -25,10 +25,11 @@ This plugin assumes you already have an app configured on Bitrise and uses a Per
|
|
25
25
|
- Check build success/failure (exiting with success or failure according to the status on Bitrise)
|
26
26
|
- Retrieve the list of artifacts from a build
|
27
27
|
- Download the artifacts produced by a build
|
28
|
+
- Automatic retry of requests when the connection to the Bitrise API fails or returns a 5xx error
|
28
29
|
|
29
30
|
### Known issues
|
30
31
|
|
31
|
-
-
|
32
|
+
- Triggering a build with a tag is not yet implemented
|
32
33
|
- The author option to trigger the build is not implemented
|
33
34
|
- The environments option to trigger the build is not implemented
|
34
35
|
- Pagination on API responses is not implemented
|
@@ -45,8 +46,10 @@ Use this action to trigger a workflow on Bitrise and query its status.
|
|
45
46
|
| `app_slug` | The app slug of the project on Bitrise | BITRISE_APP_SLUG | |
|
46
47
|
| `access_token` | The [personal access token](https://devcenter.bitrise.io/api/authentication/) used to call Bitrise API | BITRISE_ACCESS_TOKEN | |
|
47
48
|
| `workflow` | The name of the workflow to trigger | BITRISE_WORKFLOW | |
|
48
|
-
| `
|
49
|
+
| `branch` | The name of branch that will be checked out | BITRISE_BUILD_BRANCH | |
|
50
|
+
| `commit_hash` | The hash of the commit that will be checked out (overrides branch parameter) | BITRISE_BUILD_COMMIT_HASH | |
|
49
51
|
| `build_message` | A custom message that will be used to identify the build | BITRISE_BUILD_MESSAGE | |
|
52
|
+
| `triggered_by` | A custom message that will be used to identify where the build was triggered from (optional) | BITRISE_BUILD_TRIGGERED_BY | |
|
50
53
|
| `wait_for_build` | Whether the action should wait until the build finishes or return immediately after requesting the build | BITRISE_WAIT_FOR_BUILD | false |
|
51
54
|
| `download_artifacts` | Whether to download or not the produced artifacts | BITRISE_DOWNLOAD_ARTIFACTS | false |
|
52
55
|
|
@@ -75,6 +78,7 @@ The returned value is a hash containing the information about the build status.
|
|
75
78
|
| `status` | The status of the build: not finished (0), successful (1), failed (2), aborted with failure (3), aborted with success (4) |
|
76
79
|
| `status_text` | The status text |
|
77
80
|
| `is_on_hold` | Indicates whether the build has started yet (true: the build hasn't started) |
|
81
|
+
| `abort_reason` | If the build has been aborted, indicates the reason why |
|
78
82
|
|
79
83
|
### bitrise_build_artifacts
|
80
84
|
Use this action to retrieve information about the artifacts of a build or to automatically download them from Bitrise.
|
@@ -24,6 +24,7 @@ module Fastlane
|
|
24
24
|
build_infos["is_on_hold"] = json_response["is_on_hold"]
|
25
25
|
build_infos["status"] = json_response["status"]
|
26
26
|
build_infos["status_text"] = json_response["status_text"]
|
27
|
+
build_infos["abort_reason"] = json_response["abort_reason"]
|
27
28
|
build_infos
|
28
29
|
end
|
29
30
|
|
@@ -5,18 +5,22 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class TriggerBitriseWorkflowAction < Action
|
7
7
|
def self.run(params)
|
8
|
-
UI.
|
8
|
+
UI.message("Requesting new Bitrise.io build for workflow '#{params[:workflow]}'...")
|
9
9
|
|
10
|
-
|
10
|
+
trigger_payload = {
|
11
11
|
hook_info: {
|
12
12
|
type: "bitrise"
|
13
13
|
},
|
14
14
|
build_params: {
|
15
|
-
workflow_id: params[:workflow]
|
16
|
-
commit_hash: params[:commit_hash],
|
17
|
-
commit_message: params[:build_message]
|
15
|
+
workflow_id: params[:workflow]
|
18
16
|
}
|
19
|
-
}
|
17
|
+
}
|
18
|
+
trigger_payload[:build_params][:branch] = params[:branch] unless params[:branch].nil? || params[:branch].empty?
|
19
|
+
trigger_payload[:build_params][:commit_hash] = params[:commit_hash] unless params[:commit_hash].nil? || params[:commit_hash].empty?
|
20
|
+
trigger_payload[:build_params][:commit_message] = params[:build_message] unless params[:build_message].nil? || params[:build_message].empty?
|
21
|
+
trigger_payload[:triggered_by] = params[:triggered_by] unless params[:triggered_by].nil? || params[:triggered_by].empty?
|
22
|
+
|
23
|
+
response = Helper::BitriseRequestHelper.post(params, 'builds', trigger_payload.to_json)
|
20
24
|
|
21
25
|
if response.code == "201"
|
22
26
|
json_response = JSON.parse(response.body)
|
@@ -24,7 +28,7 @@ module Fastlane
|
|
24
28
|
FastlaneCore::PrintTable.print_values(config: json_response,
|
25
29
|
title: "Bitrise API response")
|
26
30
|
else
|
27
|
-
UI.crash!("Error requesting new build on Bitrise.io. Status code: #{response.code}. #{response}")
|
31
|
+
UI.crash!("Error requesting new build on Bitrise.io. Status code: #{response.code}. #{response.body}")
|
28
32
|
end
|
29
33
|
|
30
34
|
build_infos = {}
|
@@ -35,14 +39,20 @@ module Fastlane
|
|
35
39
|
|
36
40
|
if params[:wait_for_build]
|
37
41
|
build_status = wait_until_build_completion(params, build_infos["build_slug"])
|
42
|
+
|
38
43
|
if params[:download_artifacts]
|
39
44
|
BitriseBuildArtifactsAction.get_artifacts(params, build_infos["build_slug"])
|
40
45
|
end
|
46
|
+
|
47
|
+
build_infos["status"] = build_status["status_text"]
|
41
48
|
if build_status["status"] == 1
|
42
49
|
UI.success("Build has finished successfully on Bitrise!")
|
43
|
-
build_infos["status"] = build_status["status_text"]
|
44
50
|
elsif build_status["status"] == 2
|
45
51
|
UI.build_failure!("Build has FAILED on Bitrise. Check more details at #{build_infos['build_url']}.")
|
52
|
+
elsif build_status["status"] == 3 || build_status["status"] == 4
|
53
|
+
UI.build_failure!("Build has been ABORTED on Bitrise. Abort reason: '#{build_status['abort_reason']}'. Check more details at #{build_infos['build_url']}.")
|
54
|
+
else
|
55
|
+
UI.build_failure!("Build has ended with unknown status on Bitrise: #{build_status}. Check more details at #{build_infos['build_url']}.")
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
@@ -96,15 +106,25 @@ module Fastlane
|
|
96
106
|
description: "The name of the workflow to trigger",
|
97
107
|
optional: false,
|
98
108
|
type: String),
|
109
|
+
FastlaneCore::ConfigItem.new(key: :branch,
|
110
|
+
env_name: "BITRISE_BUILD_BRANCH",
|
111
|
+
description: "The name of branch that will be checked out",
|
112
|
+
optional: true,
|
113
|
+
type: String),
|
99
114
|
FastlaneCore::ConfigItem.new(key: :commit_hash,
|
100
115
|
env_name: "BITRISE_BUILD_COMMIT_HASH",
|
101
116
|
description: "The hash of the commit that will be checked out",
|
102
|
-
optional:
|
117
|
+
optional: true,
|
103
118
|
type: String),
|
104
119
|
FastlaneCore::ConfigItem.new(key: :build_message,
|
105
120
|
env_name: "BITRISE_BUILD_MESSAGE",
|
106
121
|
description: "A custom message that will be used to identify the build",
|
107
|
-
optional:
|
122
|
+
optional: true,
|
123
|
+
type: String),
|
124
|
+
FastlaneCore::ConfigItem.new(key: :triggered_by,
|
125
|
+
env_name: "BITRISE_BUILD_TRIGGERED_BY",
|
126
|
+
description: "A custom message that will be used to identify where the build was triggered from",
|
127
|
+
optional: true,
|
108
128
|
type: String),
|
109
129
|
FastlaneCore::ConfigItem.new(key: :wait_for_build,
|
110
130
|
env_name: "BITRISE_WAIT_FOR_BUILD",
|
@@ -5,16 +5,17 @@ module Fastlane
|
|
5
5
|
|
6
6
|
module Helper
|
7
7
|
class BitriseRequestHelper
|
8
|
+
MAX_RETRY_ATTEMPTS = 2
|
8
9
|
class << self
|
9
10
|
def get(params, path)
|
10
11
|
request = Net::HTTP::Get.new("/v0.1/apps/#{params[:app_slug]}/#{path}", bitrise_headers(params[:access_token]))
|
11
|
-
|
12
|
+
request_with_retries(request)
|
12
13
|
end
|
13
14
|
|
14
15
|
def post(params, path, body)
|
15
16
|
request = Net::HTTP::Post.new("/v0.1/apps/#{params[:app_slug]}/#{path}", bitrise_headers(params[:access_token]))
|
16
17
|
request.body = body
|
17
|
-
|
18
|
+
request_with_retries(request)
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
@@ -29,6 +30,29 @@ module Fastlane
|
|
29
30
|
def bitrise_headers(access_token)
|
30
31
|
{ 'Content-Type' => 'application/json', 'Authorization' => access_token }
|
31
32
|
end
|
33
|
+
|
34
|
+
def request_with_retries(request)
|
35
|
+
retries = 0
|
36
|
+
begin
|
37
|
+
response = bitrise_client.request(request)
|
38
|
+
if response.code.start_with?("5")
|
39
|
+
UI.error("Bitrise returned a server-side error. Status code: #{response.code}. #{response}")
|
40
|
+
raise "Bitrise API error: #{response.code}"
|
41
|
+
end
|
42
|
+
rescue StandardError => e
|
43
|
+
UI.error("There was an error making the request to Bitrise (retries: #{retries}). #{e}")
|
44
|
+
if retries < MAX_RETRY_ATTEMPTS
|
45
|
+
retries += 1
|
46
|
+
sleep(15)
|
47
|
+
UI.error("Retrying request (attempt #{retries})")
|
48
|
+
retry
|
49
|
+
else
|
50
|
+
UI.error("All retry attempts failed.")
|
51
|
+
raise e
|
52
|
+
end
|
53
|
+
end
|
54
|
+
response
|
55
|
+
end
|
32
56
|
end
|
33
57
|
end
|
34
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-bitrise_automation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Cecchi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|