forked from thyrlian/AwesomeValidation
/
Jenkinsfile
50 lines (43 loc) · 1.04 KB
/
Jenkinsfile
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
node('android') {
stage('Checkout') {
checkout scm
}
stage('Clean') {
sh "./gradlew clean"
}
stage('Static Analysis') {
checkLintAndPublishResults()
}
stage('Unit Test') {
runUnitTestAndPublishResults()
}
stage('Assemble') {
generateAndArchiveAPK()
}
}
def checkLintAndPublishResults() {
try {
sh "./gradlew :library:lint"
} catch(err) {
}
String file = "library/build/outputs/lint-results-debug.xml"
step([$class: 'LintPublisher', pattern: file])
}
def runUnitTestAndPublishResults() {
failure = false
try {
sh "./gradlew :library:testDebugUnitTest"
} catch(err) {
failure = true
} finally {
String results = "library/build/test-results/testDebugUnitTest/*.xml"
step([$class: 'JUnitResultArchiver', testResults: results])
}
if (failure) {
error('Unit Test failed')
}
}
def generateAndArchiveAPK() {
sh "./gradlew :demo:assembleDebug"
archive "demo/build/outputs/apk/*.apk"
}