-
Notifications
You must be signed in to change notification settings - Fork 11
/
sonar-project.js
35 lines (31 loc) · 959 Bytes
/
sonar-project.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const argv = require('minimist')(process.argv.slice(2));
const sonarqubeScanner = require("sonarqube-scanner");
const branch = argv['branch'];
const targetBranch = argv['target-branch'];
const pullRequestId = argv['pull-request-id'];
const sonarOptions = {
"sonar.organization": "ontotext-ad",
"sonar.projectKey": "Ontotext-AD_graphdb.js",
"sonar.projectName": "graphdb.js",
"sonar.sources": "./src",
"sonar.tests": "test",
"sonar.language": "js",
"sonar.javascript.lcov.reportPaths": "coverage/lcov.info",
"sonar.scm.provider": "git",
"sonar.sourceEncoding": "UTF-8",
};
if (pullRequestId) {
sonarOptions['sonar.pullrequest.key'] = `${pullRequestId}`;
sonarOptions['sonar.pullrequest.branch'] = branch;
sonarOptions['sonar.pullrequest.base'] = targetBranch;
} else {
sonarOptions["sonar.branch.name"] = branch;
}
sonarqubeScanner(
{
options: sonarOptions
},
() => {
console.log('Finished SonarQube scan');
},
);