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

Function getSentryRelease

packages/vercel-edge/src/sdk.ts:201–303  ·  view source on GitHub ↗
(fallback?: string)

Source from the content-addressed store, hash-verified

199 */
200// eslint-disable-next-line complexity
201export function getSentryRelease(fallback?: string): string | undefined {
202 // Always read first as Sentry takes this as precedence
203 if (process.env.SENTRY_RELEASE) {
204 return process.env.SENTRY_RELEASE;
205 }
206
207 // This supports the variable that sentry-webpack-plugin injects
208 if (GLOBAL_OBJ.SENTRY_RELEASE?.id) {
209 return GLOBAL_OBJ.SENTRY_RELEASE.id;
210 }
211
212 // This list is in approximate alpha order, separated into 3 categories:
213 // 1. Git providers
214 // 2. CI providers with specific environment variables (has the provider name in the variable name)
215 // 3. CI providers with generic environment variables (checked for last to prevent possible false positives)
216
217 const possibleReleaseNameOfGitProvider =
218 // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
219 process.env['GITHUB_SHA'] ||
220 // GitLab CI - https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
221 process.env['CI_MERGE_REQUEST_SOURCE_BRANCH_SHA'] ||
222 process.env['CI_BUILD_REF'] ||
223 process.env['CI_COMMIT_SHA'] ||
224 // Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
225 process.env['BITBUCKET_COMMIT'];
226
227 const possibleReleaseNameOfCiProvidersWithSpecificEnvVar =
228 // AppVeyor - https://www.appveyor.com/docs/environment-variables/
229 process.env['APPVEYOR_PULL_REQUEST_HEAD_COMMIT'] ||
230 process.env['APPVEYOR_REPO_COMMIT'] ||
231 // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
232 process.env['CODEBUILD_RESOLVED_SOURCE_VERSION'] ||
233 // AWS Amplify - https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html
234 process.env['AWS_COMMIT_ID'] ||
235 // Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
236 process.env['BUILD_SOURCEVERSION'] ||
237 // Bitrise - https://devcenter.bitrise.io/builds/available-environment-variables/
238 process.env['GIT_CLONE_COMMIT_HASH'] ||
239 // Buddy CI - https://buddy.works/docs/pipelines/environment-variables#default-environment-variables
240 process.env['BUDDY_EXECUTION_REVISION'] ||
241 // Builtkite - https://buildkite.com/docs/pipelines/environment-variables
242 process.env['BUILDKITE_COMMIT'] ||
243 // CircleCI - https://circleci.com/docs/variables/
244 process.env['CIRCLE_SHA1'] ||
245 // Cirrus CI - https://cirrus-ci.org/guide/writing-tasks/#environment-variables
246 process.env['CIRRUS_CHANGE_IN_REPO'] ||
247 // Codefresh - https://codefresh.io/docs/docs/codefresh-yaml/variables/
248 process.env['CF_REVISION'] ||
249 // Codemagic - https://docs.codemagic.io/yaml-basic-configuration/environment-variables/
250 process.env['CM_COMMIT'] ||
251 // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
252 process.env['CF_PAGES_COMMIT_SHA'] ||
253 // Drone - https://docs.drone.io/pipeline/environment/reference/
254 process.env['DRONE_COMMIT_SHA'] ||
255 // Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
256 process.env['FC_GIT_COMMIT_SHA'] ||
257 // Heroku #1 https://devcenter.heroku.com/articles/heroku-ci
258 process.env['HEROKU_TEST_RUN_COMMIT_VERSION'] ||

Callers 1

initFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected