-
Notifications
You must be signed in to change notification settings - Fork 7
/
sonar.gradle
75 lines (69 loc) · 3.54 KB
/
sonar.gradle
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
apply plugin: 'org.sonarqube'
def branch = System.getenv("BITRISE_GIT_BRANCH")
def pRBranch = System.getenv("BITRISE_PULL_REQUEST")
def pRTargetBranch = System.getenv("BITRISEIO_GIT_BRANCH_DEST")
def tagName = System.getenv("BITRISE_GIT_TAG")
def isRelease = tagName != null && tagName != ""
sonarqube {
properties {
property 'sonar.sourceEncoding', 'UTF-8'
property 'sonar.projectName', 'Android SDK Utils'
property 'sonar.host.url', System.getenv("SONARQUBE_HOST_URL")
property 'sonar.login', System.getenv("SONARQUBE_TOKEN")
property 'sonar.projectKey', System.getenv("SONARQUBE_PROJ_KEY")
property 'sonar.projectVersion', scmVersion.version
/* Tags */
if (isRelease) {
// Since tags don't have an explicit branch and can point to any commit, let us use the tag name
// as branch name property. In Sonarqube, the tag is going to appear same level as other branches
// with its own analysis.
property 'sonar.branch.name', tagName
}
/* Branch analysis */
else if (!pRBranch) {
property 'sonar.branch.name', branch
/* PR analysis */
} else {
property 'sonar.pullrequest.key', pRBranch.findAll(/\d+/)*.toInteger().last()
property 'sonar.pullrequest.branch', branch
property 'sonar.pullrequest.base', pRTargetBranch
}
property 'sonar.qualitygate.wait', true
/* Dependency Check */
property 'sonar.dependencyCheck.skip', System.getenv("SONAR_DEPENDENCYCHECK_SKIP")
property 'sonar.dependencyCheck.jsonReportPath', 'build/reports/dependency-check-report.json'
property 'sonar.dependencyCheck.htmlReportPath', 'build/reports/dependency-check-report.html'
/* Dependency Check severity minimum score, will have the Sonarqube default values when not set */
property 'sonar.dependencyCheck.severity.blocker', System.getenv("SONAR_DEPENDENCYCHECK_SEVERITY_BLOCKER") ?: 8
property 'sonar.dependencyCheck.severity.critical', System.getenv("SONAR_DEPENDENCYCHECK_SEVERITY_CRITICAL") ?: 7
property 'sonar.dependencyCheck.severity.major', System.getenv("SONAR_DEPENDENCYCHECK_SEVERITY_MAJOR") ?: 4
property 'sonar.dependencyCheck.severity.minor', System.getenv("SONAR_DEPENDENCYCHECK_SEVERITY_MINOR") ?: 0
}
}
subprojects { subproject ->
sonarqube {
properties {
property 'sonar.sources', 'src'
property 'sonar.exclusions', '**/test/**, ' +
'**/*Generated.java, ' +
'build/**, ' +
'*.json, ' +
'**/*test*/**, ' +
'**/.gradle/**, ' +
'**/R.class'
property 'sonar.test.inclusions', '**/test/**'
property 'sonar.coverage.jacoco.xmlReportPaths',
isRelease ? 'build/reports/jacoco/jacocoReleaseReport/jacocoReleaseReport.xml' :
'build/reports/jacoco/jacocoDebugReport/jacocoDebugReport.xml'
property 'sonar.junit.reportPaths',
isRelease ? 'build/test-results/testReleaseUnitTest' :
'build/test-results/testDebugUnitTest'
}
}
}
// sample module is a sample app to test sdk utils functions which should be excluded from sdk-utils
project(':sample') {
sonarqube {
skipProject = true
}
}