-
Notifications
You must be signed in to change notification settings - Fork 16
/
sonar-project.js
34 lines (30 loc) · 1001 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
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-workbench",
"sonar.projectName": "graphdb-workbench",
"sonar.sources": "./src",
"sonar.exclusions": "src/res/**/*,src/font/**/*,src/js/lib/**/*,src/css/fonts/**/*,src/css/lib/**/*",
"sonar.language": "js",
"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');
},
);