forked from learningequality/kolibri-installer-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
124 lines (109 loc) · 3.77 KB
/
Jenkinsfile
File metadata and controls
124 lines (109 loc) · 3.77 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Jenkins pipeline
// https://www.jenkins.io/doc/book/pipeline/
//
// Required parameters: UPLOAD
pipeline {
agent {
dockerfile {
// Try to use the same node to make use of caching.
reuseNode true
}
}
environment {
// pre-commit, Gradle and the Android Gradle Plugin cache outputs in
// the home directory. Point them inside the workspace.
XDG_CACHE_HOME = "$WORKSPACE/_cache"
GRADLE_USER_HOME = "$WORKSPACE/_cache/.gradle"
ANDROID_USER_HOME = "$WORKSPACE/_cache/.android"
// Set the versionCode property based on the build number. At one point
// a release was made from the PR job, which had a build number far
// ahead of the standard job.
ORG_GRADLE_PROJECT_versionCode = "${currentBuild.number + 169}"
}
options {
ansiColor('xterm')
// This is needed to allow the upload job to copy the built
// artifacts.
copyArtifactPermission('kolibri-installer-android-upload')
}
stages {
stage('Lint') {
steps {
sh 'pre-commit run --all-files --show-diff-on-failure'
}
}
stage('Test') {
steps {
sh './gradlew check'
}
}
stage('APK') {
steps {
sh './gradlew build'
archiveArtifacts artifacts: 'app/build/outputs/apk/*/*.apk, app/build/outputs/version-*.json'
}
}
stage('AAB') {
// Don't create signed bundles for PRs.
when {
expression { !params.ghprbPullId }
}
steps {
withCredentials(
[[$class: 'VaultCertificateCredentialsBinding',
credentialsId: 'google-play-upload-key',
keyStoreVariable: 'UPLOAD_KEYSTORE',
passwordVariable: 'UPLOAD_PASSWORD']]
) {
writeFile(
file: 'upload.properties',
text: """\
storeFile=${env.UPLOAD_KEYSTORE}
storePassword=${env.UPLOAD_PASSWORD}
keyAlias=upload
""".stripIndent(),
)
sh './gradlew bundle'
archiveArtifacts artifacts: 'app/build/outputs/bundle/*/*.aab'
}
}
}
}
post {
always {
buildDescription("UPLOAD=${params.UPLOAD}")
}
cleanup {
sh 'rm -f upload.properties'
}
success {
script {
if (!params.ghprbPullId && params.UPLOAD) {
echo "Upload the built Kolibri Android packages for internal testers"
build(
job: 'kolibri-installer-android-upload',
parameters: [
string(name: 'RELEASE_NOTES', value: '[]'),
]
)
}
}
}
failure {
// Send email on failures when this not a PR. Unfortunately,
// there's no declarative pipeline step to test for this
// besides wrapping in a script block and checking for one
// of the ghprb environment variables.
script {
if (!env.ghprbPullId) {
emailext (
to: 'apps@endlessos.org,$DEFAULT_RECIPIENTS',
replyTo: 'apps@endlessos.org',
subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
)
}
}
}
}
}