Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 92c9011

Browse files
authored
Merge pull request #13 from getsentry/feat/sentry-release-var
Adds sentryRelease and releasePrefix parameters. Modify README.md
2 parents 115b454 + c519626 commit 92c9011

File tree

4 files changed

+42
-28
lines changed

4 files changed

+42
-28
lines changed

README.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@ Before proceeding, you'll first want to ensure that your Sentry project is set u
1212
Make sure build plugins are enabled on your site to see the plugin run.
1313

1414
## Installation
15+
#### UI Installation
16+
To install plugins via the Netlify UI, go to your team sites list and select the Plugins tab (or follow this direct link to the [plugins directory](https://app.netlify.com/plugins)). Then find "Sentry Build Plugin" and click **Install**.
1517

16-
To install, add the following lines to your `netlify.toml` file:
18+
UI installation is the recommended way to install this Build Plugin unless you need advanced configuration.
19+
20+
#### File-based Installation
21+
Alternatively, to install with file-based installation, add the following lines to your `netlify.toml` file:
1722

1823
```toml
1924
[[plugins]]
2025
package = "@sentry/netlify-build-plugin"
26+
27+
[plugins.inputs]
28+
sentryOrg = ""
29+
sentryProject = ""
2130
```
2231

23-
Note: The `[[plugins]]` line is required for each plugin, even if you have other plugins in your `netlify.toml` file already.
32+
Note: The `[[plugins]]` line is required for each plugin installed via file-based installation, even if you have other plugins in your `netlify.toml` file already.
2433

2534
### Create a Sentry Internal Integration
2635
For Netlify to communicate securely with Sentry, you'll need to create a new internal integration. In Sentry, navigate to: *Settings > Developer Settings > New Internal Integration*.
@@ -33,25 +42,30 @@ Click “Save” at the bottom of the page and grab your token, which you’ll n
3342

3443

3544
### Set Environment Variables in Netlify
36-
Save the internal integration token as a [site environment variable](https://docs.netlify.com/configure-builds/environment-variables/):
45+
Save the internal integration token and any other environment variables as [site environment variables](https://docs.netlify.com/configure-builds/environment-variables/):
3746
1. In Netlify, go to your site's settings.
3847
2. Click on "Build & deploy".
39-
3. Add a new environment variable and enter `SENTRY_AUTH_TOKEN` as the name and your internal integration token as the value.
48+
3. Click “Edit variables” and add `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`, and `SENTRY_PROJECT` with their respective values. For more configuration options see the [environment variables](#environment-variables) section below.
49+
4. Click "Save".
4050

4151
![View of internal integration permissions.](images/netlify-environment-variables.png)
4252

43-
### Configuration
44-
Configure the plugin with your Sentry settings:
45-
```toml
46-
[[plugins]]
47-
package = "@sentry/netlify-build-plugin"
53+
For more information about the parameters below, please see the [Sentry release management docs](https://docs.sentry.io/cli/releases/).
4854

49-
[plugins.inputs]
50-
sentryOrg = ""
51-
sentryProject = ""
52-
```
55+
### Ensure Your SDK is Configured
56+
To link errors with releases, you must include a release ID (a.k.a version) where you configure your client SDK. For more information, read our documentation on [configuring your SDK for releases](https://docs.sentry.io/workflow/releases/?platform=node#configure-sdk).
5357

54-
For more information about the parameters below, please see the [Sentry release management docs](https://docs.sentry.io/cli/releases/).
58+
#### Environment Variables
59+
60+
You can use [site environment variables](https://docs.netlify.com/configure-builds/environment-variables/) to configure these values:
61+
| name | description | default |
62+
|------|-------------|---------|
63+
| `SENTRY_AUTH_TOKEN` | Authentication token for Sentry. | - |
64+
| `SENTRY_ORG` | The slug of the organization name in Sentry. | - |
65+
| `SENTRY_PROJECT` | The slug of the project name in Sentry. | - |
66+
| `SENTRY_RELEASE` | The release ID (a.k.a version). | [COMMIT_REF](https://docs.netlify.com/configure-builds/environment-variables/#git-metadata) |
67+
| `SENTRY_ENVIRONMENT` | The name of the environment being deployed to. | Netlify [deploy context](https://docs.netlify.com/site-deploys/overview/#deploy-contexts) |
68+
| `SENTRY_RELEASE_PREFIX` | Set this to prefix the release name with the value. | - |
5569

5670

5771
#### Plugin Inputs
@@ -60,17 +74,9 @@ For more information about the parameters below, please see the [Sentry release
6074
| `sentryOrg` | The slug of the organization name in Sentry. | - |
6175
| `sentryProject` | The slug of the project name in Sentry. | - |
6276
| `sentryAuthToken` | Authentication token for Sentry. We recommend this be set as an environment variable (see below). | - |
77+
| `sentryRelease` | The release ID (a.k.a version). | [COMMIT_REF](https://docs.netlify.com/configure-builds/environment-variables/#git-metadata) |
6378
| `sourceMapPath` | Folder in which to scan for source maps to upload. | Netlify publish directory |
6479
| `sourceMapUrlPrefix` | Prefix for the location of source maps. | `"~/"` |
6580
| `skipSetCommits` | Set this to true if you want to disable commit tracking. | `false` |
6681
| `skipSourceMaps` | Set this to true if you want to disable sending source maps to Sentry. | `false` |
67-
68-
#### Environment Variables
69-
70-
You can also use [site environment variables](https://docs.netlify.com/configure-builds/environment-variables/) to configure these values:
71-
| name | description | default |
72-
|------|-------------|---------|
73-
| `SENTRY_AUTH_TOKEN` | Authentication token for Sentry. | - |
74-
| `SENTRY_ORG` | The slug of the organization name in Sentry. | - |
75-
| `SENTRY_PROJECT` | The slug of the project name in Sentry. | - |
76-
| `SENTRY_ENVIRONMENT` | The name of the environment being deployed to. | Netlify [deploy context](https://docs.netlify.com/site-deploys/overview/#deploy-contexts) |
82+
| `releasePrefix` | Set this to prefix the release name with the value. | - |
12.9 KB
Loading

index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ module.exports = {
2828
const sentryOrg = process.env.SENTRY_ORG || inputs.sentryOrg
2929
const sentryProject = process.env.SENTRY_PROJECT || inputs.sentryProject
3030
const sentryAuthToken = process.env.SENTRY_AUTH_TOKEN || inputs.sentryAuthToken
31+
const sentryRelease = process.env.SENTRY_RELEASE || inputs.sentryRelease || process.env.COMMIT_REF
32+
const releasePrefix = process.env.SENTRY_RELEASE_PREFIX || inputs.releasePrefix || ''
3133
const sentryEnvironment = process.env.SENTRY_ENVIRONMENT || process.env.CONTEXT
3234
const sourceMapPath = inputs.sourceMapPath || PUBLISH_DIR
3335
const sourceMapUrlPrefix = inputs.sourceMapUrlPrefix || DEFAULT_SOURCE_MAP_URL_PREFIX
@@ -45,10 +47,13 @@ module.exports = {
4547

4648
await createSentryConfig({ sentryOrg, sentryProject, sentryAuthToken })
4749

50+
/* Apply release prefix */
51+
const release = `${releasePrefix}${sentryRelease}`
52+
4853
/* Notify Sentry of release being deployed on Netlify */
49-
await sentryRelease({
54+
await createSentryRelease({
5055
pluginApi,
51-
sentryAuthToken,
56+
release,
5257
sentryEnvironment,
5358
sourceMapPath,
5459
sourceMapUrlPrefix,
@@ -65,10 +70,9 @@ module.exports = {
6570
}
6671
}
6772

68-
async function sentryRelease({ pluginApi, sentryAuthToken, sentryEnvironment, sourceMapPath, sourceMapUrlPrefix, skipSetCommits, skipSourceMaps }) {
73+
async function createSentryRelease({ pluginApi, release, sentryEnvironment, sourceMapPath, sourceMapUrlPrefix, skipSetCommits, skipSourceMaps }) {
6974
// default config file is read from ~/.sentryclirc
7075
const { constants, inputs, utils } = pluginApi
71-
const release = process.env.COMMIT_REF
7276
const cli = new SentryCli()
7377

7478
console.log('Creating new release with version: ', release)

manifest.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ inputs:
66
description: The slug of the project name in Sentry
77
- name: sentryAuthToken
88
description: Authentication token for Sentry
9+
- name: sentryRelease
10+
description: The release ID (a.k.a version)
911
- name: sourceMapPath
1012
description: Folder in which to scan for source maps to upload
1113
- name: sourceMapUrlPrefix
@@ -16,3 +18,5 @@ inputs:
1618
- name: skipSourceMaps
1719
description: Set this to true if you want to disable sending source maps to Sentry
1820
default: False
21+
- name: releasePrefix
22+
description: Set this to prefix the release name with the value.

0 commit comments

Comments
 (0)