Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Sonar CLI mirror and version variables #57

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ var sonarqubeScanner = require('sonarqube-scanner').customScanner;
## Download From Mirrors

By default, SonarQube scanner binaries are downloaded from `https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/`.
To use a custom mirror, set `$SONAR_SCANNER_MIRROR`.
To use a custom mirror, set `$SONAR_SCANNER_MIRROR`. Or download precise version with `$SONAR_SCANNER_VERSION`

**Example:**
```shell
export SONAR_SCANNER_MIRROR=https://npm.taobao.org/mirrors/sonar-scanner/
export SONAR_SCANNER_VERSION=3.2.0.1227
```

or alternatively set variable in `.npmrc`

```
sonar_scanner_mirror=https://npm.taobao.org/mirrors/sonar-scanner/
sonar_scanner_version=3.2.0.1227
```

## License
Expand Down
7 changes: 5 additions & 2 deletions dist/sonarqube-scanner-executable.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module.exports.prepareExecEnvironment = prepareExecEnvironment
module.exports.getSonarQubeScannerExecutable = getSonarQubeScannerExecutable
module.exports.getLocalSonarQubeScannerExecutable = getLocalSonarQubeScannerExecutable

const SONAR_SCANNER_MIRROR = 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/'
const SONAR_SCANNER_VERSION = '3.2.0.1227'

const bar = new ProgressBar('[:bar] :percent :etas', {
complete: '=',
incomplete: ' ',
Expand Down Expand Up @@ -56,7 +59,7 @@ function prepareExecEnvironment(params, process) {
* Returns the SQ Scanner executable for the current platform
*/
function getSonarQubeScannerExecutable(passExecutableCallback) {
const platformBinariesVersion = '3.2.0.1227'
const platformBinariesVersion = process.env.SONAR_SCANNER_VERSION || process.env.npm_config_sonar_scanner_version || SONAR_SCANNER_VERSION
var targetOS = findTargetOS()
var installFolder = path.join(os.homedir(), '.sonar', 'native-sonar-scanner')
var binaryExtension = ''
Expand Down Expand Up @@ -91,7 +94,7 @@ function getSonarQubeScannerExecutable(passExecutableCallback) {
log('Proceed with download of the platform binaries for SonarQube Scanner...')
log('Creating ' + installFolder)
mkdirs(installFolder)
var baseUrl = process.env.SONAR_SCANNER_MIRROR || 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/'
var baseUrl = process.env.SONAR_SCANNER_MIRROR || process.env.npm_config_sonar_scanner_mirror || SONAR_SCANNER_MIRROR;
var fileName = 'sonar-scanner-cli-' + platformBinariesVersion + '-' + targetOS + '.zip'
var downloadUrl = baseUrl + fileName
log(`Downloading from ${downloadUrl}`)
Expand Down