Commit 71a3b0cc authored by Robert Knight's avatar Robert Knight

Upload JS bundles to Sentry and set correct URL prefix

Fix several issues with the Sentry file uploads which prevented Sentry
from using the uploaded files.

 - Upload the JS bundles to Sentry as well as the sourcemaps. Sentry
   reads the `sourceMappingURL` comment from the JS

 - Set the correct URL prefix for the files, so that Sentry knows that
   eg. "sidebar.bundle.js" is served at https://cdn.hypothes.is/hypothesis/$VERSION/build/scripts/sidebar.bundle.js

   For Sentry to use a file uploaded in a release, the artifact name
   (URL prefix + name) must match the URL from which it is served (and
   referenced in crash reports). The origin of the URL can optionally be
   shortened to `~`, but we haven't done that here.

 - Finalize the release after uploading files
parent 978abeaa
...@@ -28,6 +28,9 @@ node { ...@@ -28,6 +28,9 @@ node {
// S3 bucket where the embedded client is served from. // S3 bucket where the embedded client is served from.
s3Bucket = "cdn.hypothes.is" s3Bucket = "cdn.hypothes.is"
// URL where the embedded client will be served from.
cdnURL = "https://${s3Bucket}/hypothesis"
// Pre-release suffix added to new package version number when deploying, // Pre-release suffix added to new package version number when deploying,
// eg. "testing". // eg. "testing".
// //
...@@ -125,11 +128,10 @@ node { ...@@ -125,11 +128,10 @@ node {
export SIDEBAR_APP_URL=https://qa.hypothes.is/app.html export SIDEBAR_APP_URL=https://qa.hypothes.is/app.html
export NOTEBOOK_APP_URL=https://qa.hypothes.is/notebook export NOTEBOOK_APP_URL=https://qa.hypothes.is/notebook
yarn version --no-git-tag-version --new-version ${qaVersion} yarn version --no-git-tag-version --new-version ${qaVersion}
yarn run sentry-cli releases --org hypothesis --project client new ${qaVersion}
yarn run sentry-cli releases --org hypothesis --project client files ${qaVersion} upload-sourcemaps build/scripts/*.map
""" """
uploadFilesToSentry(cdnURL, qaVersion)
// Deploy to S3, so the package can be served by // Deploy to S3, so the package can be served by
// https://qa.hypothes.is/embed.js. // https://qa.hypothes.is/embed.js.
// //
...@@ -199,11 +201,10 @@ stage('Publish') { ...@@ -199,11 +201,10 @@ stage('Publish') {
export SIDEBAR_APP_URL=https://hypothes.is/app.html export SIDEBAR_APP_URL=https://hypothes.is/app.html
export NOTEBOOK_APP_URL=https://hypothes.is/notebook export NOTEBOOK_APP_URL=https://hypothes.is/notebook
yarn version --no-git-tag-version --new-version ${newPkgVersion} yarn version --no-git-tag-version --new-version ${newPkgVersion}
yarn run sentry-cli releases --org hypothesis --project client new ${newPkgVersion}
yarn run sentry-cli releases --org hypothesis --project client files ${newPkgVersion} upload-sourcemaps build/scripts/*.map
""" """
uploadFilesToSentry(cdnURL, newPkgVersion)
// Create GitHub release with changes since previous release. // Create GitHub release with changes since previous release.
sh "scripts/create-github-release.js v${pkgVersion}" sh "scripts/create-github-release.js v${pkgVersion}"
...@@ -246,3 +247,16 @@ String bumpMinorVersion(String version) { ...@@ -246,3 +247,16 @@ String bumpMinorVersion(String version) {
return "${parts[0]}.${newMinorVersion}.${parts[2]}" return "${parts[0]}.${newMinorVersion}.${parts[2]}"
} }
// Upload the source files and sourcemaps for a new release to Sentry.
//
// See https://docs.sentry.io/product/cli/releases/#sentry-cli-sourcemaps.
void uploadFilesToSentry(String cdnURL, String version) {
def sentryCmd = "yarn run sentry-cli releases --org hypothesis --project client"
sh """
${sentryCmd} new ${version}
${sentryCmd} files ${version} upload-sourcemaps --url-prefix ${cdnURL}/${version}/build/scripts/ build/scripts/
${sentryCmd} finalize ${version}
"""
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment