getsentry / sentry-fastlane-plugin

Official fastlane plugin for Sentry
https://sentry.io
MIT License
136 stars 50 forks source link
crash-reporting dsym fastlane hacktoberfest sentry sourcemaps tag-production team-mobile


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:

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.