Skip to content

Commit

Permalink
SLVSCODE-951 Use token from Vault to upload source maps in CI builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jblievremont committed Jan 9, 2025
1 parent 68041d9 commit 16868a8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
1 change: 1 addition & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
ARTIFACTORY_DEPLOY_REPO: sonarsource-public-qa
NPM_CONFIG_registry: https://repox.jfrog.io/artifactory/api/npm/npm
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
SENTRY_UPLOAD_TOKEN: VAULT[development/kv/data/sentry/sq-ide-upload data.token]

ARTIFACTORY_PRIVATE_READER_USERNAME: $ARTIFACTORY_PRIVATE_USERNAME
ARTIFACTORY_PRIVATE_READER_PASSWORD: $ARTIFACTORY_PRIVATE_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion build-sonarlint/deployUtils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getPackageJSON } from './fsUtils.mjs';
import { join, extname, basename } from 'path';
import dateformat from 'dateformat';
import { computeDependencyHashes, fileHashsum } from './hashes.mjs';
import jarDependencies from '../scripts/dependencies.json' assert { type: "json" } ;
import jarDependencies from '../scripts/dependencies.json' with { type: "json" } ;
import { createReadStream } from 'fs';
import fetch, { Headers } from 'node-fetch';
import { globbySync } from 'globby';
Expand Down
45 changes: 31 additions & 14 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@

const path = require('path');

const plugins = [];
// Must be injected by CI environment
if (process.env.SENTRY_UPLOAD_TOKEN) {
/**@type {import('webpack').WebpackPluginFunction}*/
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');
plugins.push(sentryWebpackPlugin({
org: 'sonar-x0',
project: 'sonarqube-vscode',
authToken: process.env.SENTRY_UPLOAD_TOKEN
}));
}

/**@type {import('webpack').Configuration}*/
const config = {
// vscode extensions run in a Node.js-context -> https://webpack.js.org/configuration/node/
Expand Down Expand Up @@ -59,6 +47,35 @@ const config = {
}
]
},
plugins
plugins: []
};
module.exports = config;

module.exports = (env, argv) => {

if (
// Only for production builds (e.g. CI)
argv.mode === 'production' &&
// Injected by Vault
process.env.SENTRY_UPLOAD_TOKEN &&
// Injected by CI
process.env.BUILD_NUMBER
) {
console.log('Enabling Sentry upload plugin');
/**@type {import('webpack').WebpackPluginFunction}*/
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');
const { version } = require('./package.json');

config.plugins.push(sentryWebpackPlugin({
org: 'sonar-x0',
project: 'sonarqube-vscode',
authToken: process.env.SENTRY_UPLOAD_TOKEN,
release: {
name: version
}
}));
} else {
console.log('Not enabling Sentry upload plugin');
}

return config;
}

0 comments on commit 16868a8

Please sign in to comment.