MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / getSentryRelease

Function getSentryRelease

packages/node-core/src/sdk/api.ts:11–113  ·  view source on GitHub ↗
(fallback?: string)

Source from the content-addressed store, hash-verified

9 */
10// eslint-disable-next-line complexity
11export function getSentryRelease(fallback?: string): string | undefined {
12 // Always read first as Sentry takes this as precedence
13 if (process.env.SENTRY_RELEASE) {
14 return process.env.SENTRY_RELEASE;
15 }
16
17 // This supports the variable that sentry-webpack-plugin injects
18 if (GLOBAL_OBJ.SENTRY_RELEASE?.id) {
19 return GLOBAL_OBJ.SENTRY_RELEASE.id;
20 }
21
22 // This list is in approximate alpha order, separated into 3 categories:
23 // 1. Git providers
24 // 2. CI providers with specific environment variables (has the provider name in the variable name)
25 // 3. CI providers with generic environment variables (checked for last to prevent possible false positives)
26
27 const possibleReleaseNameOfGitProvider =
28 // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
29 process.env['GITHUB_SHA'] ||
30 // GitLab CI - https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
31 process.env['CI_MERGE_REQUEST_SOURCE_BRANCH_SHA'] ||
32 process.env['CI_BUILD_REF'] ||
33 process.env['CI_COMMIT_SHA'] ||
34 // Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
35 process.env['BITBUCKET_COMMIT'];
36
37 const possibleReleaseNameOfCiProvidersWithSpecificEnvVar =
38 // AppVeyor - https://www.appveyor.com/docs/environment-variables/
39 process.env['APPVEYOR_PULL_REQUEST_HEAD_COMMIT'] ||
40 process.env['APPVEYOR_REPO_COMMIT'] ||
41 // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
42 process.env['CODEBUILD_RESOLVED_SOURCE_VERSION'] ||
43 // AWS Amplify - https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html
44 process.env['AWS_COMMIT_ID'] ||
45 // Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
46 process.env['BUILD_SOURCEVERSION'] ||
47 // Bitrise - https://devcenter.bitrise.io/builds/available-environment-variables/
48 process.env['GIT_CLONE_COMMIT_HASH'] ||
49 // Buddy CI - https://buddy.works/docs/pipelines/environment-variables#default-environment-variables
50 process.env['BUDDY_EXECUTION_REVISION'] ||
51 // Builtkite - https://buildkite.com/docs/pipelines/environment-variables
52 process.env['BUILDKITE_COMMIT'] ||
53 // CircleCI - https://circleci.com/docs/variables/
54 process.env['CIRCLE_SHA1'] ||
55 // Cirrus CI - https://cirrus-ci.org/guide/writing-tasks/#environment-variables
56 process.env['CIRRUS_CHANGE_IN_REPO'] ||
57 // Codefresh - https://codefresh.io/docs/docs/codefresh-yaml/variables/
58 process.env['CF_REVISION'] ||
59 // Codemagic - https://docs.codemagic.io/yaml-basic-configuration/environment-variables/
60 process.env['CM_COMMIT'] ||
61 // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
62 process.env['CF_PAGES_COMMIT_SHA'] ||
63 // Drone - https://docs.drone.io/pipeline/environment/reference/
64 process.env['DRONE_COMMIT_SHA'] ||
65 // Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
66 process.env['FC_GIT_COMMIT_SHA'] ||
67 // Heroku #1 https://devcenter.heroku.com/articles/heroku-ci
68 process.env['HEROKU_TEST_RUN_COMMIT_VERSION'] ||

Callers 5

resolveReleaseNameFunction · 0.90
getReleaseFunction · 0.90
getReleaseFunction · 0.90
detectSentryReleaseFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected