-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
71 lines (67 loc) · 2.08 KB
/
Jenkinsfile
File metadata and controls
71 lines (67 loc) · 2.08 KB
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
pipeline {
agent any
environment {
APIKEY = credentials("accuweather-apikey")
EMAILPW = credentials("gmail-app-password")
SENDER = credentials("sender-email")
RECEIVER = credentials("receiver-email")
}
stages {
stage("Download APK") {
steps {
sh '''
mkdir -p tests/src/test/resources/apks
gdown "https://drive.google.com/uc?id=1KWK34l1I9OxdaSwk5m3IZmn90tn0g1TF" -O tests/src/test/resources/apks/AccuWeather.apk
'''
}
}
stage("Inject secrets into properties") {
steps {
dir('tests') {
script {
def testProps = readFile('src/test/resources/test.properties')
testProps = testProps.replace("apikey={your.accuweather.api.key}", "apikey=${env.APIKEY}")
writeFile file: 'test.properties', text: testProps
}
}
dir('post-report') {
script {
def emailProps = readFile('src/main/resources/email.properties')
emailProps = emailProps.replace("email-application-password={application.password}", "email-application-password=${env.EMAILPW}")
emailProps = emailProps.replace("sender-email={sender.email}", "sender-email=${env.SENDER}")
emailProps = emailProps.replace("receiver-email={receiver.email}", "receiver-email=${env.RECEIVER}")
writeFile file: 'email.properties', text: emailProps
}
}
}
}
stage("Log test properties") {
steps {
sh 'cat tests/src/test/resources/test.properties'
}
}
stage("Log email properties") {
steps {
sh 'cat post-report/src/main/resources/email.properties'
}
}
stage("Run Tests") {
steps {
dir("tests") {
sh "mvn clean test"
}
}
}
}
post {
always {
// These always run, even if a previous stage fails
dir("tests") {
sh "mvn surefire-report:report || true" // use '|| true' to avoid stopping on error
}
dir("post-report") {
sh "mvn clean install exec:java || true"
}
}
}
}