Class: Fastlane::Helper::SentryConfig
- Inherits:
-
Object
- Object
- Fastlane::Helper::SentryConfig
- Defined in:
- lib/fastlane/plugin/sentry/helper/sentry_config.rb
Class Method Summary collapse
- .build_vcs_command(command, params) ⇒ Object
- .common_api_config_items ⇒ Object
- .common_cli_config_items ⇒ Object
- .common_vcs_config_items ⇒ Object
- .fallback_sentry_cli_auth(params) ⇒ Object
- .parse_api_params(params) ⇒ Object
Class Method Details
.build_vcs_command(command, params) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/fastlane/plugin/sentry/helper/sentry_config.rb', line 142 def self.build_vcs_command(command, params) 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 << "--force-git-metadata" if params[:force_git_metadata] command << "--no-git-metadata" if params[:no_git_metadata] command end |
.common_api_config_items ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fastlane/plugin/sentry/helper/sentry_config.rb', line 16 def self.common_api_config_items [ FastlaneCore::ConfigItem.new(key: :url, env_name: "SENTRY_URL", description: "Url for Sentry", is_string: true, optional: true), FastlaneCore::ConfigItem.new(key: :auth_token, env_name: "SENTRY_AUTH_TOKEN", description: "Authentication token for Sentry", optional: true), FastlaneCore::ConfigItem.new(key: :org_slug, env_name: "SENTRY_ORG_SLUG", description: "Organization slug for Sentry project", optional: true), FastlaneCore::ConfigItem.new(key: :project_slug, env_name: "SENTRY_PROJECT_SLUG", description: "Project slug for Sentry", optional: true), FastlaneCore::ConfigItem.new(key: :log_level, env_name: "SENTRY_LOG_LEVEL", description: "Configures the log level used by sentry-cli", optional: true, verify_block: proc do |value| UI.user_error! "Invalid log level '#{value}'" unless ['trace', 'debug', 'info', 'warn', 'error'].include? value.downcase end) ] + self.common_cli_config_items end |
.common_cli_config_items ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/fastlane/plugin/sentry/helper/sentry_config.rb', line 4 def self.common_cli_config_items [ FastlaneCore::ConfigItem.new(key: :sentry_cli_path, env_name: "SENTRY_CLI_PATH", description: "Path to your sentry-cli. Defaults to `which sentry-cli`", optional: true, verify_block: proc do |value| UI.user_error! "'#{value}' is not executable" unless FastlaneCore::Helper.executable?(value) end) ] end |
.common_vcs_config_items ⇒ Object
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/fastlane/plugin/sentry/helper/sentry_config.rb', line 87 def self.common_vcs_config_items [ 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: :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 |
.fallback_sentry_cli_auth(params) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/fastlane/plugin/sentry/helper/sentry_config.rb', line 156 def self.fallback_sentry_cli_auth(params) sentry_cli_result = JSON.parse(SentryHelper.call_sentry_cli( params, [ "info", "--config-status-json" ] )) return (sentry_cli_result["auth"]["successful"] && !sentry_cli_result["auth"]["type"].nil?) end |
.parse_api_params(params) ⇒ Object
45 46 47 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 |
# File 'lib/fastlane/plugin/sentry/helper/sentry_config.rb', line 45 def self.parse_api_params(params) require 'shellwords' url = params[:url] auth_token = params[:auth_token] org = params[:org_slug] project = params[:project_slug] log_level = params[:log_level] has_org = !org.to_s.empty? has_project = !project.to_s.empty? has_auth_token = !auth_token.to_s.empty? ENV['SENTRY_URL'] = url unless url.to_s.empty? if log_level.to_s.empty? ENV['SENTRY_LOG_LEVEL'] = 'debug' if FastlaneCore::Globals.verbose? else ENV['SENTRY_LOG_LEVEL'] = log_level end # Fallback to .sentryclirc if possible when no auth token is provided if !has_auth_token && fallback_sentry_cli_auth(params) UI.important("No auth config provided, will fallback to .sentryclirc") else # Will fail if no authentication token is provided unless has_auth_token UI.user_error!("No authentication token found for SentryAction given, pass using `auth_token: 'token'`") end ENV['SENTRY_AUTH_TOKEN'] = auth_token unless auth_token.to_s.empty? end if has_org && has_project ENV['SENTRY_ORG'] = Shellwords.escape(org) unless org.to_s.empty? ENV['SENTRY_PROJECT'] = Shellwords.escape(project) unless project.to_s.empty? elsif !has_org UI.important("Missing 'org_slug' parameter. Provide both 'org_slug' and 'project_slug'. Falling back to .sentryclirc") elsif !has_project UI.important("Missing 'project_slug' parameter. Provide both 'org_slug' and 'project_slug'. Falling back to .sentryclirc") end end |