The Rollbar CLI provides easy command line access to Rollbar's API features, starting with source map uploads and notifying deploys.
Note: The official Rollbar CLI supports source map uploads and deployments, but it does not cover the full set of API-driven workflows some teams want. If you are looking for a CLI that wraps the Rollbar REST API, check out these community-maintained projects:
These tools are community-maintained (not officially supported by Rollbar). We are linking them because they are actively maintained and have been helpful for customers.
npm install -g rollbar-cli
Currently upload-sourcemaps and notify-deploy commands are supported.
Upload source maps for a build directory (scanned recursively), a single bundle file, or a single source map file.
rollbar-cli upload-sourcemaps <path> [options]
upload sourcemaps
Options:
--version Show version number [boolean]
-v, --verbose Verbose status output [boolean]
-q, --quiet Silent status output [boolean]
--help Show help [boolean]
--access-token Access token for the Rollbar API [string] [required]
--url-prefix Base part of the stack trace URLs [string] [required]
--code-version Code version string must match value in the Rollbar item
[string] [required]
--bundle-name Bundle the map is for, when <path> is a single map not named
<bundle>.map, e.g. main.jsbundle [string]
--next Next version. Zip all the source map files and upload as one
file [boolean]
-D, --dry-run Scan and validate source maps without uploading [boolean]
Some of these options are required and must be specified for a successful upload.
path: Absolute or relative path to a build directory, a single bundle file, or a
single source map file. The directory is scanned recursively for .js, .jsbundle and .bundle
files, and each file's map is found through its sourceMappingURL directive. React Native
bundles (.jsbundle, .bundle) without a directive, such as Hermes bytecode, use the
<bundle>.map file next to them. A .map file is uploaded for the bundle it is named after,
so main.jsbundle.map is uploaded for main.jsbundle. A source map with any other name, such
as sourcemap.ios.js, needs --bundle-name. React Native bundles are uploaded under
the bundle name alone, even when they are found in a subdirectory of path.
--access-token: The Rollbar API post_server_item token.
--url-prefix: The base portion of the URL to be concatenated with the js filenames
discovered while scanning path. The Rollbar backend uses this to match stack frame locations
and it must exactly match the URLs in the error stack frames. See minified_url at
Source Maps for more information.
--code-version: The code version string must match the string passed in the Rollbar
error payload, which is usually set in the config options for Rollbar.js.
See Source Maps for more information.
--bundle-name: The bundle a single source map file is for, such as main.jsbundle. The map is
uploaded for <url-prefix><bundle-name>. Required when path is a source map whose name doesn't
end in <bundle>.map; only valid when path is a single file.
--next: This is an optional parameter triggering next version. When specified, all source map files
are compressed and uploaded as one zip file directly. Each map is uploaded for the same URL as
without --next.
Example:
rollbar-cli upload-sourcemaps ./dist --access-token 638d... --url-prefix 'http://example.com/' --code-version 123.456
or
rollbar-cli upload-sourcemaps ./dist --access-token 638d... --url-prefix 'http://example.com/' --code-version 123.456 --next
Rollbar's React Native SDK reports stack frames as http://reactnativehost/<bundle name>,
so use http://reactnativehost/ as the --url-prefix, and either name the map after the bundle
(main.jsbundle.map on iOS, index.android.bundle.map on Android) or pass --bundle-name.
For a map generated as in Rollbar's React Native docs,
with react-native bundle --bundle-output ios/main.jsbundle --sourcemap-output sourcemap.ios.js:
rollbar-cli upload-sourcemaps sourcemap.ios.js --bundle-name main.jsbundle --access-token 638d... --url-prefix 'http://reactnativehost/' --code-version 1.2.3
On Android, --sourcemap-output sourcemap.android.js goes with --bundle-name index.android.bundle.
The bundle is uploaded as http://reactnativehost/<bundle name> whichever directory it is
found in, so prefer pointing path at one bundle or map: a whole build folder can hold several
copies of the same bundle, and the CLI warns when more than one map would upload under the
same name. --next uploads React Native maps under the same names. Pointing path at the map
file directly also works for Hermes builds:
rollbar-cli upload-sourcemaps android/app/build/generated/sourcemaps/react/release/index.android.bundle.map --access-token 638d... --url-prefix 'http://reactnativehost/' --code-version 1.2.3
or at a bundle produced by react-native bundle --bundle-output build/main.jsbundle --sourcemap-output build/main.jsbundle.map:
rollbar-cli upload-sourcemaps build/main.jsbundle --access-token 638d... --url-prefix 'http://reactnativehost/' --code-version 1.2.3
Notify deploy to Rollbar.
rollbar-cli notify-deploy [options]
Notify deploy to Rollbar
Options:
--version Show version number [boolean]
-v, --verbose Verbose status output [boolean]
-q, --quiet Silent status output [boolean]
--help Show help [boolean]
--access-token Use a post server item access token for the Rollbar API
[string] [required]
--code-version Code version or Git SHA of revision being deployed
[string] [required]
--deploy-id ID of the deploy to update [string]
--environment Environment to which the revision was deployed such as
production [string] [required]
--status Status of the deploy - started, succeeded (default),
failed, or timed_out [string]
--rollbar-username Rollbar username of person who deployed [string]
--local-username Local username of person who deployed [string]
--comment Additional text to include with the deploy [string]
Example:
rollbar-cli notify-deploy --access-token 1234 --code-version 1.0.1 --environment production --rollbar-username foobar --status succeeded --local-username foo_bar --comment 'Deploy Test'
Output on success:
{ deploy_id: 12345678 }
Deploy successful
See our Releases page for a list of all releases, including changes.
If you run into any issues, please email us at support@rollbar.com.
For bug reports, please open an issue on GitHub.
To set up a development environment, you'll need Node.js and npm.
-
Install dependencies
npm install -
Link the rollbar-cli command to the local repo
npm link -
Run the tests
npm test
- Fork it.
- Create your feature branch (
git checkout -b my-new-feature). - Commit your changes (
git commit -am 'Added some feature'). - Push to the branch (
git push origin my-new-feature). - Create a new Pull Request.
rollbar-cli is free software released under the MIT License. See LICENSE for details.