-
Notifications
You must be signed in to change notification settings - Fork 122
/
Jenkinsfile
153 lines (153 loc) · 7.45 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
pipeline {
agent {
label 'android'
}
stages {
stage('Setup') {
steps {
echo "Repository checkout complete!"
sh 'chmod +x gradlew'
}
}
stage('Build') {
steps {
sh './gradlew clean distZipBundleJres'
archiveArtifacts 'desktop/build/distributions/DestinationSol.zip'
}
}
stage('Analytics') {
steps {
sh "./gradlew check javadoc"
}
}
stage('Record') {
steps {
junit testResults: '**/build/test-results/test/*.xml', allowEmptyResults: true
recordIssues tool: javaDoc()
step([$class: 'JavadocArchiver', javadocDir: 'engine/build/docs/javadoc', keepAll: false])
recordIssues tool: checkStyle(pattern: '**/build/reports/checkstyle/*.xml')
recordIssues tool: findBugs(pattern: '**/build/reports/findbugs/*.xml', useRankAsPriority: true)
recordIssues tool: pmdParser(pattern: '**/build/reports/pmd/*.xml')
recordIssues tool: taskScanner(includePattern: '**/*.java,**/*.groovy,**/*.gradle', lowTags: 'WIBNIF', normalTags: 'TODO', highTags: 'ASAP')
}
}
stage('Build Android') {
steps {
sh 'echo sdk.dir=/opt/android-sdk > local.properties'
dir('android') {
script {
// Allow varying from the default Android repo path for easier development. Assume same Android branch as engine branch.
def androidGitPath = "https://github.com/MovingBlocks/DestSolAndroid.git"
if (env.PUBLISH_ORG) {
androidGitPath = androidGitPath.replace("MovingBlocks", env.PUBLISH_ORG)
println "Updated target Android Git path to: " + androidGitPath
} else {
println "Not varying the Android path from default " + androidGitPath
}
// Figure out a suitable target branch in the Android repo, default is the develop branch
def androidBranch = "develop"
// Check to see if Jenkins is building a tag, branch, or other (including PRs)
if (env.TAG_NAME != null && env.TAG_NAME ==~ /v\d+\.\d+\.\d+.*/) {
println "Going to use target Android tag " + env.TAG_NAME
androidBranch = "refs/tags/" + env.TAG_NAME
} else if (env.BRANCH_NAME.equalsIgnoreCase("master") || env.BRANCH_NAME.startsWith("android/")) {
println "Going to use target unusual Android branch " + env.BRANCH_NAME
androidBranch = env.BRANCH_NAME
} else {
println "Going to use target Android branch 'develop' - not building 'master' nor anything starting with 'android/'"
}
checkout scm: [$class: 'GitSCM', branches: [[name: androidBranch]], extensions: [], userRemoteConfigs: [[credentialsId: 'GooeyHub', url: androidGitPath]]]
}
}
sh './gradlew :android:assembleDebug'
archiveArtifacts 'android/build/outputs/apk/debug/android-debug.apk'
}
}
stage('Record Android') {
steps {
sh './gradlew :android:lint'
recordIssues tool: androidLintParser(pattern: 'android/build/reports/lint-results.xml')
}
}
stage('Notify') {
environment {
WEBHOOK = credentials('destsolDiscordWebhook')
}
steps {
discordSend title: env.BRANCH_NAME, link: env.BUILD_URL, result: currentBuild.currentResult, webhookURL: env.WEBHOOK
}
}
stage('Publish to Play Store') {
when {
// Example: v2.1.0
tag pattern: 'v\\d+\\.\\d+\\.\\d+.*', comparator: "REGEXP"
}
environment {
DESTSOL_ANDROID_SIGNING_KEYSTORE=credentials('destsol-signing-keystore')
DESTSOL_ANDROID_SIGNING_STORE_PASS=credentials('destsol-keystore-pass')
DESTSOL_ANDROID_SIGNING_KEY_ALIAS=credentials('destsol-signing-alias')
DESTSOL_ANDROID_SINGING_KEY_PASS=credentials('destsol-signing-pass')
DESTSOL_PLAYSTORE_SECRET=credentials('destsol-playstore-secret')
WEBHOOK = credentials('destsolDiscordWebhook')
}
stages {
stage('Prepare Fastlane') {
steps {
dir('android') {
sh 'ln -s $DESTSOL_PLAYSTORE_SECRET playstore_secret.json'
}
}
}
stage('Create Release APK') {
steps {
dir('android') {
sh 'fastlane buildRelease'
archiveArtifacts 'build/outputs/apk/release/android-release.apk'
}
}
}
// Leaving this stage inside a parallel as only one can ever be true at once (pipeline visualization aesthetics!)
stage('Target release channel') {
parallel {
stage('Publish Alpha To Play Store') {
when {
// Example: v2.1.0-alpha
tag pattern: 'v\\d+\\.\\d+\\.\\d+-alpha$', comparator: "REGEXP"
}
steps {
dir('android') {
sh 'fastlane deployAlpha'
}
}
}
stage('Publish Beta To Play Store') {
when {
// Example: v2.1.0-beta
tag pattern: 'v\\d+\\.\\d+\\.\\d+-beta$', comparator: "REGEXP"
}
steps {
dir('android') {
sh 'fastlane deployBeta'
}
discordSend title: "Beta ${env.GIT_TAG} published to Play Store", result: currentBuild.currentResult, webhookURL: env.WEBHOOK
}
}
stage('Publish Live To Play Store') {
when {
// Example: v2.1.0
// This intentionally does not include things like v2.1.0-beta
tag pattern: 'v\\d+\\.\\d+\\.\\d+$', comparator: "REGEXP"
}
steps {
dir('android') {
sh 'fastlane deployProduction'
}
discordSend title: "Release ${env.GIT_TAG} published to Play Store", result: currentBuild.currentResult, webhookURL: env.WEBHOOK
}
}
}
}
}
}
}
}