Skip to content

getsentry/sentry-fastlane-plugin

Repository files navigation


Sentry Fastlane Plugin

fastlane Plugin Badge Tests Gem Version

Getting Started

This project is a fastlane plugin. To get started with fastlane-plugin-sentry, you can either add it globally for all projects, or locally to an individual project.

Globally

If you install the gem globally, you can run it with any project that is setup for using fastlane.

gem install fastlane-plugin-sentry

Add the actions you want to use to your Fastfile file and call fastlane to run.

Locally

You can also add the plugin for individual projects. Navigate to your project where fastlane is already set up and run the following command:

bundle exec fastlane add_plugin sentry

Fastlane will guide you through the process. It will add a Pluginfile where the sentry plugin is listed and also update the Gemfile and Gemfile.lock to include it as a dependency.

# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-sentry'

Add the actions you want to use to your Fastfile file and call bundle exec fastlane to run.

Sentry Actions

A subset of actions provided by the CLI: https://docs.sentry.io/learn/cli/

Authentication & Configuration

auth_token is the preferred authentication method with Sentry. This can be obtained on https://sentry.io/api/. api_key still works but will eventually become deprecated. This can be obtained through the settings of your project. Also note that as of version 1.2.0 you no longer have to provide the required parameters, we will try to fallback to your .sentryclirc config file if possible.

The following environment variables may be used in place of parameters: SENTRY_API_KEY, SENTRY_AUTH_TOKEN, SENTRY_ORG_SLUG, and SENTRY_PROJECT_SLUG.

Uploading Debug Information Files

sentry_debug_files_upload(
  api_key: '...', # Do not use if using auth_token
  auth_token: '...', # Do not use if using api_key
  org_slug: '...',
  project_slug: '...',
  path: '/path/to/files', # Optional. Defaults to '.' when no value is provided. Path(s) can be a string, a comma-separated string, or an array of strings.
)

The SENTRY_DSYM_PATH environment variable may be used in place of the dsym_path parameter.

Further options:

  • type: Optional. Only consider debug information files of the given type. By default, all types are considered. Valid options: 'dsym', 'elf', 'breakpad', 'pdb', 'pe', 'sourcebundle', 'bcsymbolmap'.
  • no_unwind: Optional. Do not scan for stack unwinding information. Specify this flag for builds with disabled FPO, or when stackwalking occurs on the device. This usually excludes executables and dynamic libraries. They might still be uploaded, if they contain additional processable information (see other flags)".
  • no_debug: Optional. Do not scan for debugging information. This will usually exclude debug companion files. They might still be uploaded, if they contain additional processable information (see other flags)".
  • no_sources: Optional. "Do not scan for source information. This will usually exclude source bundle files. They might still be uploaded, if they contain additional processable information (see other flags)".
  • ids: Optional. Search for specific debug identifiers.
  • require_all: Optional. Errors if not all identifiers specified with --id could be found.
  • symbol_maps: Optional. Optional path to BCSymbolMap files which are used to resolve hidden symbols in dSYM files downloaded from iTunes Connect. This requires the dsymutil tool to be available.
  • derived_data: Optional. Search for debug symbols in Xcode's derived data.
  • no_zips: Do not search in ZIP files.
  • info_plist: Optional. Optional path to the Info.plist. We will try to find this automatically if run from Xcode. Providing this information will associate the debug symbols with a specific ITC application and build in Sentry. Note that if you provide the plist explicitly it must already be processed.
  • no_reprocessing: Optional. Do not trigger reprocessing after uploading.
  • force_foreground: Optional. Wait for the process to finish. By default, the upload process will detach and continue in the background when triggered from Xcode. When an error happens, a dialog is shown. If this parameter is passed Xcode will wait for the process to finish before the build finishes and output will be shown in the Xcode build output.
  • include_sources: Optional. Include sources from the local file system and upload them as source bundles.
  • wait: Wait for the server to fully process uploaded files. Errors can only be displayed if --wait is specified, but this will significantly slow down the upload process.
  • upload_symbol_maps: Optional. Upload any BCSymbolMap files found to allow Sentry to resolve hidden symbols, e.g. when it downloads dSYMs directly from App Store Connect or when you upload dSYMs without first resolving the hidden symbols using --symbol-maps.

Or the deprecated ways, which will be removed in the next major update:

sentry_upload_dif(
  api_key: '...', # Do not use if using auth_token
  auth_token: '...', # Do not use if using api_key
  org_slug: '...',
  project_slug: '...',
  path: '/path/to/files', # Optional. Defaults to '.' when no value is provided. Path(s) can be a string, a comma-separated string, or an array of strings.
)
sentry_upload_dsym(
  api_key: '...', # Do not use if using auth_token
  auth_token: '...', # Do not use if using api_key
  org_slug: '...',
  project_slug: '...',
  symbol_maps: 'path to bcsymbols folder', # use this if you have a bcsymbols folder
  dsym_path: './App.dSYM.zip',
  info_plist: '...' # optional, sentry-cli tries to find the correct plist by itself
)

Creating & Finalizing Releases

sentry_create_release(
  api_key: '...',
  auth_token: '...',
  org_slug: '...',
  project_slug: '...',
  version: '...', # release version to create
  app_identifier: '...', # pass in the bundle_identifer of your app
  finalize: true # Whether to finalize the release. If not provided or false, the release can be finalized using the sentry_finalize_release action
)

Uploading Files & Sourcemaps

Useful for uploading build artifacts and JS sourcemaps for react-native apps built using fastlane.

sentry_upload_sourcemap(
  api_key: '...',
  auth_token: '...',
  org_slug: '...',
  project_slug: '...',
  version: '...',
  app_identifier: '...', # pass in the bundle_identifer of your app
  build: '...', # Optionally pass in the build number of your app
  dist: '...', # optional distribution of the release usually the buildnumber
  sourcemap: ['main.jsbundle', 'main.jsbundle.map'], # Sourcemap(s) to upload. Path(s) can be a comma-separated string or an array of strings.
  rewrite: true
)

Uploading Proguard Mapping File

sentry_upload_proguard(
  api_key: '...', # Do not use if using auth_token
  auth_token: '...', # Do not use if using api_key
  org_slug: '...',
  project_slug: '...',
  android_manifest_path: 'path to merged AndroidManifest file', # found in `app/build/intermediates/manifests/full`
  mapping_path: 'path to mapping.txt to upload',
)

Associating commits

Useful for telling Sentry which commits are associated with a release.

sentry_set_commits(
  version: '...',
  app_identifier: '...', # pass in the bundle_identifer of your app
  build: '...', # Optionally pass in the build number of your app
  auto: false, # enable completely automated commit management
  clear: false, # clear all current commits from the release
  commit: '...', # commit spec, see `sentry-cli releases help set-commits` for more information
  ignore_missing: false # Optional boolean value: When the flag is set and the previous release commit was not found in the repository, will create a release with the default commits count (or the one specified with `--initial-depth`) instead of failing the command.
)

Create deploy

Creates a new release deployment for a project on Sentry.

sentry_create_deploy(
  api_key: '...', # Do not use if using auth_token
  auth_token: '...', # Do not use if using api_key
  org_slug: '...',
  project_slug: '...',
  version: '...',
  app_identifier: '...', # pass in the bundle_identifer of your app
  build: '...', # Optionally pass in the build number of your app
  env: 'staging', # The environment for this deploy. Required.
  name: '...', # Optional human readable name
  deploy_url: '...', # Optional URL that points to the deployment
  started: 1622630647, # Optional unix timestamp when the deployment started
  finished: 1622630700, # Optional unix timestamp when the deployment finished
  time: 180 # Optional deployment duration in seconds. This can be specified alternatively to `started` and `finished`
)

Specify custom sentry-cli path

Starting with version 1.13.0, the plugin bundles both macOS and Windows 64 bit executables of sentry-cli. You can also specify a custom sentry-cli path by adding sentry_cli_path to any action.

Checking the sentry-cli is installed

Useful for checking that the sentry-cli is installed and meets the minimum version requirements before starting to build your app in your lane.

sentry_check_cli_installed()

Logging

You can set the sentry-cli configuration value SENTRY_LOG_LEVEL by adding log_level to any action. Supported values are 'trace', 'debug', 'info', 'warn' and 'error'.

Issues and Feedback

For any other issues and feedback about this plugin, please submit it to this repository.

Troubleshooting

For some more detailed help with plugins problems, check out the Plugins Troubleshooting doc in the main fastlane repo.

Using fastlane Plugins

For more information about how the fastlane plugin system works, check out the Plugins documentation in the main fastlane repo.

About fastlane

fastlane automates building, testing, and releasing your app for beta and app store distributions. To learn more about fastlane, check out fastlane.tools.