Skip to content

Commit cbc2cc6

Browse files
committed
Add InstabugBuildAndroidAppAction for Android build with metadata reporting
1 parent 3b70c1e commit cbc2cc6

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
require 'fastlane/action'
2+
require_relative '../helper/instabug_stores_upload_helper'
3+
4+
module Fastlane
5+
module Actions
6+
class InstabugBuildAndroidAppAction < Action
7+
def self.run(params)
8+
UI.message("Starting Instabug Android build...")
9+
10+
# Extract Instabug-specific parameters
11+
branch_name = params.delete(:branch_name)
12+
instabug_api_key = params.delete(:instabug_api_key)
13+
14+
# Validate required parameters
15+
if branch_name.nil? || branch_name.empty?
16+
UI.user_error!("branch_name is required for Instabug reporting")
17+
end
18+
19+
begin
20+
# Report build start to Instabug
21+
Helper::InstabugStoresUploadHelper.report_status(
22+
branch_name: branch_name,
23+
api_key: instabug_api_key,
24+
status: "inprogress",
25+
step: "build_app"
26+
)
27+
28+
# Execute the actual Android build using gradle
29+
result = Actions::GradleAction.run(params)
30+
31+
# Report build success to Instabug
32+
Helper::InstabugStoresUploadHelper.report_status(
33+
branch_name: branch_name,
34+
api_key: instabug_api_key,
35+
status: "success",
36+
step: "build_app"
37+
)
38+
39+
UI.success("Android build completed successfully!")
40+
result
41+
rescue => e
42+
UI.error("Android build failed: #{e.message}")
43+
44+
# Report build failure to Instabug
45+
Helper::InstabugStoresUploadHelper.report_status(
46+
branch_name: branch_name,
47+
api_key: instabug_api_key,
48+
status: "failure",
49+
step: "build_app"
50+
)
51+
raise e
52+
end
53+
end
54+
55+
def self.description
56+
"Build Android app with Instabug metadata reporting"
57+
end
58+
59+
def self.authors
60+
["Instabug Company"]
61+
end
62+
63+
def self.return_value
64+
"Returns the result from gradle action"
65+
end
66+
67+
def self.details
68+
"This action wraps the standard gradle action and adds Instabug-specific metadata reporting. It tracks build events per branch and provides better observability for engineering teams."
69+
end
70+
71+
def self.available_options
72+
# Start with the original gradle options
73+
options = Actions::GradleAction.available_options
74+
75+
# Add Instabug-specific options
76+
instabug_options = [
77+
FastlaneCore::ConfigItem.new(
78+
key: :branch_name,
79+
env_name: "INSTABUG_BRANCH_NAME",
80+
description: "The branch name for tracking builds",
81+
optional: false,
82+
type: String
83+
),
84+
FastlaneCore::ConfigItem.new(
85+
key: :instabug_api_key,
86+
env_name: "INSTABUG_API_KEY",
87+
description: "Instabug API key for reporting build events",
88+
optional: false,
89+
type: String,
90+
sensitive: true
91+
)
92+
]
93+
94+
# Combine both sets of options
95+
options + instabug_options
96+
end
97+
98+
def self.is_supported?(platform)
99+
platform == :android
100+
end
101+
102+
def self.example_code
103+
[
104+
'instabug_build_android_app(
105+
branch_name: "main",
106+
instabug_api_key: "your-api-key",
107+
task: "assembleRelease",
108+
project_dir: "android/",
109+
properties: {
110+
"android.injected.signing.store.file" => "keystore.jks",
111+
"android.injected.signing.store.password" => "password",
112+
"android.injected.signing.key.alias" => "key0",
113+
"android.injected.signing.key.password" => "password"
114+
}
115+
)'
116+
]
117+
end
118+
119+
def self.category
120+
:building
121+
end
122+
end
123+
end
124+
end

0 commit comments

Comments
 (0)