-
Notifications
You must be signed in to change notification settings - Fork 11
/
sonar.gradle
83 lines (77 loc) · 3.63 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
75
76
77
78
79
80
81
82
83
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 In-App Messaging SDK'
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 */
property 'sonar.dependencyCheck.severity.blocker', System.getenv("DEPENDENCY_CHECK_FAILBUID_CVSS")
property 'sonar.dependencyCheck.severity.critical', System.getenv("DEPENDENCY_CHECK_FAILBUID_CVSS")
property 'sonar.dependencyCheck.severity.major', System.getenv("DEPENDENCY_CHECK_FAILBUID_CVSS")
property 'sonar.dependencyCheck.severity.minor', System.getenv("DEPENDENCY_CHECK_FAILBUID_CVSS")
}
}
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'
}
}
}
// test module is a sample app to test inappmessaging library,
// and should be excluded from analysis
project(':test') {
sonarqube {
skipProject = true
}
}
// the analytics module doesn't includes code sources,
// and should be excluded from analysis
project(':analytics') {
sonarqube {
skipProject = true
}
}