Class: Fastlane::Actions::SentryUploadBuildAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/sentry/actions/sentry_upload_build.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



123
124
125
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_build.rb', line 123

def self.authors
  ["runningcode"]
end

.available_optionsObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_build.rb', line 48

def self.available_options
  Helper::SentryConfig.common_api_config_items + [
    FastlaneCore::ConfigItem.new(key: :xcarchive_path,
                                 description: "Path to your iOS build archive (.xcarchive)",
                                 default_value: Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE],
                                 verify_block: proc do |value|
                                   UI.user_error!("Could not find xcarchive at path '#{value}'") unless File.exist?(value)
                                   UI.user_error!("Path '#{value}' is not an xcarchive") unless File.extname(value) == '.xcarchive'
                                 end),
    FastlaneCore::ConfigItem.new(key: :head_sha,
                                 env_name: "SENTRY_HEAD_SHA",
                                 description: "The SHA of the head of the current branch",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :base_sha,
                                 env_name: "SENTRY_BASE_SHA",
                                 description: "The SHA of the base branch",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :vcs_provider,
                                 env_name: "SENTRY_VCS_PROVIDER",
                                 description: "The version control system provider (e.g., 'github', 'gitlab')",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :head_repo_name,
                                 env_name: "SENTRY_HEAD_REPO_NAME",
                                 description: "The name of the head repository",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :base_repo_name,
                                 env_name: "SENTRY_BASE_REPO_NAME",
                                 description: "The name of the base repository",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :head_ref,
                                 env_name: "SENTRY_HEAD_REF",
                                 description: "The name of the head branch",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :base_ref,
                                 env_name: "SENTRY_BASE_REF",
                                 description: "The name of the base branch",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :pr_number,
                                 env_name: "SENTRY_PR_NUMBER",
                                 description: "The pull request number",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :build_configuration,
                                 env_name: "SENTRY_BUILD_CONFIGURATION",
                                 description: "The build configuration (e.g., 'Release', 'Debug')",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :release_notes,
                                 description: "The release notes to use for the upload",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :force_git_metadata,
                                 description: "Force collection and sending of git metadata (branch, commit, etc.). \
                                 If neither this nor --no-git-metadata is specified, git metadata is automatically \
                                 collected when running in most CI environments",
                                 is_string: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :no_git_metadata,
                                 description: "Disable collection and sending of git metadata",
                                 is_string: false,
                                 optional: true)
  ]
end

.descriptionObject



40
41
42
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_build.rb', line 40

def self.description
  "Upload iOS build archive to Sentry with optional git context"
end

.detailsObject



44
45
46
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_build.rb', line 44

def self.details
  "This action allows you to upload iOS build archives (.xcarchive) to Sentry with optional git-related parameters for enhanced context including commit SHAs, branch names, repository information, and pull request details."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_build.rb', line 127

def self.is_supported?(platform)
  [:ios].include?(platform)
end

.return_valueObject



119
120
121
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_build.rb', line 119

def self.return_value
  nil
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_build.rb', line 4

def self.run(params)
  Helper::SentryConfig.parse_api_params(params)

  # Verify xcarchive path
  xcarchive_path = params[:xcarchive_path]
  UI.user_error!("Could not find xcarchive at path '#{xcarchive_path}'") unless File.exist?(xcarchive_path)
  UI.user_error!("Path '#{xcarchive_path}' is not an xcarchive") unless File.extname(xcarchive_path) == '.xcarchive'

  command = [
    "build",
    "upload",
    File.absolute_path(xcarchive_path)
  ]

  # Add git-related parameters if provided
  command << "--head-sha" << params[:head_sha] if params[:head_sha]
  command << "--base-sha" << params[:base_sha] if params[:base_sha]
  command << "--vcs-provider" << params[:vcs_provider] if params[:vcs_provider]
  command << "--head-repo-name" << params[:head_repo_name] if params[:head_repo_name]
  command << "--base-repo-name" << params[:base_repo_name] if params[:base_repo_name]
  command << "--head-ref" << params[:head_ref] if params[:head_ref]
  command << "--base-ref" << params[:base_ref] if params[:base_ref]
  command << "--pr-number" << params[:pr_number] if params[:pr_number]
  command << "--build-configuration" << params[:build_configuration] if params[:build_configuration]
  command << "--release-notes" << params[:release_notes] if params[:release_notes]
  command << "--force-git-metadata" if params[:force_git_metadata]
  command << "--no-git-metadata" if params[:no_git_metadata]

  Helper::SentryHelper.call_sentry_cli(params, command)
  UI.success("Successfully uploaded build archive: #{xcarchive_path}")
end