-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
101 lines (101 loc) · 4.2 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
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
def webhookUrl = 'https://discord.com/api/webhooks/1081761276797128754/0yXcIoxXm_aui4VhomSpuUXfOFNO1V12NGJQSGP0DsX-LGUuxXba9mLOj15F0iYdDWcY'
pipeline {
agent any
options {
skipDefaultCheckout true
buildDiscarder logRotator(
artifactDaysToKeepStr: '30'
)
}
stages {
stage('Setup') {
steps {
script {
def title = "Build started: ${env.JOB_NAME.split('/')[0]}"
def description = """
Branch: ${env.BRANCH_NAME}
Build: ${env.BUILD_NUMBER}
""".stripIndent()
discordSend title: title, description: description, result: currentBuild.currentResult, link: env.JOB_DISPLAY_URL, webhookURL: webhookUrl
}
checkout scm
sh 'chmod +x -R ${WORKSPACE}'
sh './gradlew clean'
withCredentials([file(credentialsId: 'angularowoGoogleServices', variable: 'google_services')]) {
writeFile file: 'app/google-services.json', text: readFile(google_services)
}
}
}
stage('Analyze') {
steps {
sh './gradlew ktlintCheck'
}
}
stage('Test debug') {
steps {
sh './gradlew testDebug'
}
}
stage('Test release') {
when {
anyOf { branch 'master'; tag 'v*.*.*' }
}
steps {
sh './gradlew testRelease'
}
}
stage('Build debug') {
steps {
withCredentials([
string(credentialsId: 'angularowoDebugApiKey', variable: 'api_key'),
]) {
sh './gradlew assembleDebug -PapiKey=${api_key}'
}
}
}
stage('Build release') {
when {
anyOf { branch 'master'; tag 'v*.*.*' }
}
steps {
withCredentials([
file(credentialsId: 'androidKeyStore', variable: 'key_store'),
string(credentialsId: 'androidKeyPass', variable: 'key_pass'),
string(credentialsId: 'androidStorePass', variable: 'store_pass'),
string(credentialsId: 'angularowoReleaseApiKey', variable: 'api_key'),
]) {
sh './gradlew assembleRelease -PsigningKeyAlias=\'key0\' -PsigningKeyPass=${key_pass} -PsigningStoreFilePath=${key_store} -PsigningStorePass=${store_pass} -PapiKey=${api_key}'
sh './gradlew bundleRelease -PsigningKeyAlias=\'key0\' -PsigningKeyPass=${key_pass} -PsigningStoreFilePath=${key_store} -PsigningStorePass=${store_pass} -PapiKey=${api_key}'
}
}
}
}
post {
always {
script {
def changelog = ""
if (currentBuild.changeSets.size() == 0) {
changelog = "No changes."
} else {
for (int i = 0; i < currentBuild.changeSets.size(); i++) {
for (int j = 0; j < currentBuild.changeSets[i].items.size(); j++) {
def entry = currentBuild.changeSets[i].items[j]
changelog = "${changelog}\n - ${entry.commitId[-6..-1]} ${entry.msg} - ${entry.author.toString()}"
}
}
}
def title = "${env.JOB_NAME.split('/')[0]}"
def description = """
|Branch: ${env.BRANCH_NAME}
|Build: ${env.BUILD_NUMBER}
|Status: ${currentBuild.currentResult.toLowerCase().capitalize()}
|Changes: $changelog
""".stripMargin()
discordSend title: title, description: description, result: currentBuild.currentResult, link: env.JOB_DISPLAY_URL, webhookURL: webhookUrl
}
}
success {
archiveArtifacts artifacts: 'app/build/outputs/apk/*/app-*.apk, app/build/outputs/bundle/release/app-release.aab, app/build/outputs/mapping/release/mapping.txt'
}
}
}