Class: Fastlane::Actions::DynatraceProcessSymbolsAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::DynatraceProcessSymbolsAction
- Defined in:
- lib/fastlane/plugin/dynatrace/actions/dynatrace_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
300 301 302 |
# File 'lib/fastlane/plugin/dynatrace/actions/dynatrace_action.rb', line 300 def self. ["MANassar/@MohamedANassar", "cynicer"] end |
.available_options ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/fastlane/plugin/dynatrace/actions/dynatrace_action.rb', line 178 def self. [ FastlaneCore::ConfigItem.new(key: :action, env_name: "FL_UPLOAD_TO_DYNATRACE_ACTION", description: "(iOS only) Action to be performed by DTXDssClient (\"upload\" or \"decode\")", default_value: "upload", is_string: true, verify_block: proc do |value| UI.user_error!("Action needs to either be \"upload\" or \"decode\"") unless (value and value == "upload" or value == "decode") end), FastlaneCore::ConfigItem.new(key: :downloadDsyms, env_name: "FL_UPLOAD_TO_DYNATRACE_DOWNLOAD_DSYMS", default_value: false, is_string: false, description: "(iOS only) Download the dSYMs from App Store Connect"), FastlaneCore::ConfigItem.new(key: :waitForDsymProcessing, env_name: "FL_UPLOAD_TO_DYNATRACE_DOWNLOAD_DSYMS_WAIT_PROCESSING", default_value: true, is_string: false, description: "(iOS only) Wait for dSYM processing to be finished"), FastlaneCore::ConfigItem.new(key: :waitForDsymProcessingTimeout, env_name: "FL_UPLOAD_TO_DYNATRACE_DOWNLOAD_DSYMS_WAIT_TIMEOUT", default_value: 1800, is_string: false, description: "(iOS only) Timeout in seconds to wait for the dSYMs be downloadable"), FastlaneCore::ConfigItem.new(key: :username, env_name: "FL_UPLOAD_TO_DYNATRACE_DOWNLOAD_DSYMS_USERNAME", description: "(iOS only) The username/AppleID to use to download the dSYMs"), FastlaneCore::ConfigItem.new(key: :os, env_name: "FL_UPLOAD_TO_DYNATRACE_OS", description: "The type of the symbol files, either \"ios\", \"tvos\" or \"android\"", sensitive: false, optional: false, verify_block: proc do |value| UI.user_error!("Please specify the type of the symbol files. Possible values are \"ios\", \"tvos\" or \"android\".") unless (value and not value.empty? and (value == "ios" || value == "tvos" || value =="android")) end), FastlaneCore::ConfigItem.new(key: :apitoken, env_name: "FL_UPLOAD_TO_DYNATRACE_apitoken", description: "Dynatrace API token with mobile symbolication permissions", verify_block: proc do |value| UI.user_error!("No Dynatrade API token for specified, pass using `apitoken: 'token'`") unless (value and not value.empty?) end), FastlaneCore::ConfigItem.new(key: :dtxDssClientPath, env_name: "FL_UPLOAD_TO_DYNATRACE_DTXDssClientPath", description: "(DEPRECATED) The path to your DTXDssClient. The DTXDssClient is downloaded and updated automatically, unless this key is set", optional: true), FastlaneCore::ConfigItem.new(key: :appId, env_name: "FL_UPLOAD_TO_DYNATRACE_APP_ID", description: "The app ID you get from your Dynatrace environment", verify_block: proc do |value| UI.user_error!("Please provide the appID for your application. Pass using `appId: 'appId'`") unless (value and not value.empty?) end), FastlaneCore::ConfigItem.new(key: :bundleId, env_name: "FL_UPLOAD_TO_DYNATRACE_BUNDLE_ID", description: "The CFBundlebundleId (iOS) / package (Android) of the application", verify_block: proc do |value| UI.user_error!("Please provide the BundleID for your app. Pass using `bundleId: 'bundleId'`") unless (value and not value.empty?) end), FastlaneCore::ConfigItem.new(key: :versionStr, env_name: "FL_UPLOAD_TO_DYNATRACE_VERSION_STRING", description: "The CFBundleShortVersionString (iOS) / versionName (Android)", verify_block: proc do |value| UI.user_error!("Please provide the CFBundleShortVersionString for your app. Pass using `versionStr: 'versionStr'`") unless (value and not value.empty?) end), FastlaneCore::ConfigItem.new(key: :version, env_name: "FL_UPLOAD_TO_DYNATRACE_VERSION", description: "The CFBundleVersion (iOS) / versionCode (Android). Is also used for the dSYM download", verify_block: proc do |value| UI.user_error!("Please provide the version for your app. Pass using `version: 'version'`") unless (value and not value.empty?) end), FastlaneCore::ConfigItem.new(key: :symbolsfile, env_name: "FL_UPLOAD_TO_DYNATRACE_SYM_FILE_PATH", description: "Path to the dSYM file to be processed. Is only used when downloadDsyms is not set. Android only: If the file exceeds 10MiB and doesn't end with *.zip it's zipped before uploading. This can be disabled by setting `symbolsfileAutoZip` to false", verify_block: proc do |value| UI.user_error!("Please provide a value for the symbol files. Pass using `symbolsfile: 'symbolsfile'`") unless (value and not value.empty?) end), FastlaneCore::ConfigItem.new(key: :symbolsfileAutoZip, env_name: "FL_UPLOAD_TO_DYNATRACE_SYM_FILE_AUTO_ZIP", default_value: true, is_string: false, description: "(Android only) Automatically zip symbolsfile if it exceeds 10MiB and doesn't already end with *.zip"), FastlaneCore::ConfigItem.new(key: :server, env_name: "FL_UPLOAD_TO_DYNATRACE_SERVER_URL", description: "The API endpoint for the Dynatrace environment (e.g. https://environmentID.live.dynatrace.com or https://dynatrace-managed.com/e/environmentID)", verify_block: proc do |value| UI.user_error!("Please provide your environment API endpoint. Pass using `server: 'server'`") unless (value and not value.empty?) end), FastlaneCore::ConfigItem.new(key: :cleanBuildArtifacts, env_name: "FL_UPLOAD_TO_DYNATRACE_CLEAN_BUILD_ARTIFACTS", default_value: true, is_string: false, description: "Clean build artifacts after processing"), FastlaneCore::ConfigItem.new(key: :tempdir, env_name: "FL_UPLOAD_TO_DYNATRACE_TEMP_DIR", description: "(OPTIONAL) Custom temporary directory for the DTXDssClient. The plugin does not take care of cleaning this directory", optional: true), FastlaneCore::ConfigItem.new(key: :debugMode, env_name: "FL_UPLOAD_TO_DYNATRACE_DEBUG_MODE", description: "Enable debug logging", default_value: false, is_string: false, optional: true) ] end |
.description ⇒ Object
170 171 172 |
# File 'lib/fastlane/plugin/dynatrace/actions/dynatrace_action.rb', line 170 def self.description "This action processes and uploads your symbol files to Dynatrace." end |
.details ⇒ Object
174 175 176 |
# File 'lib/fastlane/plugin/dynatrace/actions/dynatrace_action.rb', line 174 def self.details "This action allows you to process and upload symbol files to Dynatrace. If you use Bitcode you can also use it to download the latest dSYM files from App Store Connect." end |
.is_supported?(platform) ⇒ Boolean
304 305 306 |
# File 'lib/fastlane/plugin/dynatrace/actions/dynatrace_action.rb', line 304 def self.is_supported?(platform) [:ios, :android].include?(platform) end |
.run(params) ⇒ Object
14 15 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 44 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 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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/fastlane/plugin/dynatrace/actions/dynatrace_action.rb', line 14 def self.run(params) UI. "DTXDssClientPath: #{params[:dtxDssClientPath]}" UI. "Parameter API Token: #{params[:apitoken]}" UI. "OS: #{params[:os]}" UI. "Version string: #{params[:versionStr]}" UI. "Version: #{params[:version]}" UI. "Server URL: #{params[:server]}" UI. "Tempdir: #{params[:tempdir]}" UI. "Checking AppFile for possible AppID" bundleId = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier) if bundleId UI. "Using #{bundleId} from your AppFile" else bundleId = params[:bundleId] UI. "BundleID: #{bundleId}" end if params[:os] == "android" symbols_path = Helper::DynatraceHelper.zip_if_required(params) response, request = Helper::DynatraceHelper.put_android_symbols(params, bundleId, symbols_path) case response.code when '204' UI.success "Success. The file has been uploaded and stored." when '400' UI.user_error! "Failed. The input is invalid." when '401' UI.user_error! "Invalid Dynatrace API token. See https://www.dynatrace.com/support/help/dynatrace-api/basics/dynatrace-api-authentication/#token-permissions and https://www.dynatrace.com/support/help/dynatrace-api/configuration-api/mobile-symbolication-api/" when '413' UI.user_error! "Failed. The symbol file storage quota is exhausted. See https://www.dynatrace.com/support/help/shortlink/mobile-symbolication#manage-the-uploaded-symbol-files for more information." else = nil unless response.body.nil? = JSON.parse(response.body)["error"]["message"] end if .nil? UI.user_error! "Symbol upload error (Response Code: #{response.code}). Please try again in a few minutes or contact the Dynatrace support (https://www.dynatrace.com/services-support/)." else UI.user_error! "Symbol upload error (Response Code: #{response.code}). #{}" end end return elsif params[:os] != "ios" && params[:os] != "tvos" UI.user_error! "Unsopported value os=#{params[:os]}" end # iOS/tvOS workflow dtxDssClientPath = Helper::DynatraceHelper.get_dss_client(params) dsym_paths = [] symbolFilesKey = "symbolsfile" # default to iOS if !OS.mac? UI.user_error! "A macOS machine is required to process iOS symbols." end if params[:downloadDsyms] == true UI. "Downloading dSYMs from App Store Connect" startTime = Time.now UI. "Checking AppFile for possible username/AppleID" username = CredentialsManager::AppfileConfig.try_fetch_value(:apple_id) if username UI. "Using #{username} from your AppFile" else username = params[:username] UI. "Didn't find a username in AppFile, using passed username parameter: #{params[:username]}" end # it takes a couple of minutes until the new build is available through the API # -> retry until available while params[:waitForDsymProcessing] and # wait is active !lane_context[SharedValues::DSYM_PATHS] and # has dsym path (Time.now - startTime) < params[:waitForDsymProcessingTimeout] # is in time Actions::DownloadDsymsAction.run(wait_for_dsym_processing: params[:waitForDsymProcessing], wait_timeout: (params[:waitForDsymProcessingTimeout] - (Time.now - startTime)).round(0), # remaining timeout app_identifier: bundleId, username: username, version: params[:version], build_number: params[:versionStr], platform: params[:os] == "ios" ? :ios : :appletvos) if !lane_context[SharedValues::DSYM_PATHS] and (Time.now - startTime) < params[:waitForDsymProcessingTimeout] UI. "Version #{params[:version]} (Build #{params[:versionStr]}) isn't listed yet, retrying in 60 seconds (timeout in #{(params[:waitForDsymProcessingTimeout] - (Time.now - startTime)).round(0)} seconds)." sleep(60) end end if (Time.now - startTime) > params[:waitForDsymProcessingTimeout] UI.user_error!("Timeout during dSYM download. Try increasing :waitForDsymProcessingTimeout.") end dsym_paths += Actions.lane_context[SharedValues::DSYM_PATHS] if Actions.lane_context[SharedValues::DSYM_PATHS] if dsym_paths.count > 0 UI. "Downloaded the dSYMs from App Store Connect. Paths: #{dsym_paths}" else raise 'No dSYM paths found!' end else UI.important "dSYM download disabled, using local path (#{params[:symbolsfile]})" dsym_paths << params[:symbolsfile] if params[:symbolsfile] end # check if we have dSYMs to proceed with if dsym_paths.count == 0 UI. "Symbol file path: #{params[:symbolsfile]}" dsym_paths = params[:symbolsfile] symbolFilesCommandSnippet = "#{symbolFilesKey}=\"#{dsym_paths}\"" else symbolFilesCommandSnippet = "#{symbolFilesKey}=\"#{dsym_paths[0]}\"" end # start constructing the command that will trigger the DTXDssClient command = [] command << "#{dtxDssClientPath}" command << "-#{params[:action]}" #"-upload" command << "appid=\"#{params[:appId]}\"" command << "apitoken=\"#{params[:apitoken]}\"" command << "os=#{params[:os]}" command << "bundleId=\"#{bundleId}\"" command << "versionStr=\"#{params[:versionStr]}\"" command << "version=\"#{params[:version]}\"" command << symbolFilesCommandSnippet command << "server=\"#{Helper::DynatraceHelper.without_trailing_slash(params[:server])}\"" command << "DTXLogLevel=ALL -verbose" if params[:debugMode] == true command << "forced=1" # if the file already exists command << "tempdir=\"#{params[:tempdir]}\"" if params[:tempdir] # Create the full shell command to trigger the DTXDssClient shell_command = command.join(' ') UI. "dSYM path: #{dsym_paths[0]}" UI. "#{shell_command}" sh("#{shell_command}", error_callback: ->(result) { # ShAction doesn't return any reference to the return value -> parse it from the output result_groups = result.match /(?:ERROR: Execution failed, rc=)(-?\d*)(?:\sreason=)(.*)/ if result_groups and result_groups.length() >= 2 if result_groups[1] == "413" UI.user_error!("DTXDssClient: #{result_groups[2]} See https://www.dynatrace.com/support/help/shortlink/mobile-symbolication#manage-the-uploaded-symbol-files for more information.") else UI.user_error!("DTXDssClient: #{result_groups[2]}") end else UI.user_error!("DTXDssClient finished with errors.") end }) if params[:cleanBuildArtifacts] UI. "Cleaning build artifacts" Fastlane::Actions::CleanBuildArtifactsAction.run(exclude_pattern: nil) end end |