forked from TW-Smart-CoE/ARK-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
125 lines (124 loc) · 4.25 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
pipeline {
agent any
environment {
// Setup Ruby to PATH
RUBY_HOME = "/usr/local/opt/ruby"
PATH = "$RUBY_HOME/bin:$PATH"
LANG = "en_US.UTF-8"
}
parameters {
string(name: 'APP_BUILD_FOLDER', defaultValue: 'app/build', description: 'Application build output folder')
choice(name: 'APP_BUILD_ENV', choices: ['dev', 'uat', 'staging'], description: 'Pipeline build env: dev/uat/staging, default is dev')
}
options {
// Stop the build early in case of compile or test failures
skipStagesAfterUnstable()
}
stages{
stage('Setup') {
steps {
script {
sh 'gem install bundler'
sh 'bundle install'
// Copy node env file to export environment variables
withCredentials([file(credentialsId: 'env-default', variable: 'env')]) {
sh 'rm -f .env.default'
sh 'cp $env .env.default'
}
}
}
}
stage('Build Dev') {
when { expression { params.APP_BUILD_ENV == 'dev'} }
steps {
script {
sh 'bundle exec fastlane build_dev'
}
}
}
stage('Build Uat') {
when { expression { params.APP_BUILD_ENV == 'uat'} }
steps {
// Copy release keystore to workspace
withCredentials([file(credentialsId: 'keystore-release', variable: 'keystore')]) {
sh 'rm -rf config/keystore'
sh 'mkdir -p config/keystore'
sh 'cp $keystore config/keystore/'
}
script {
sh 'bundle exec fastlane build_uat'
}
}
}
stage('Build Staging') {
when { expression { params.APP_BUILD_ENV == 'staging'} }
steps {
// Copy release keystore to workspace
withCredentials([file(credentialsId: 'keystore-release', variable: 'keystore')]) {
sh 'rm -rf config/keystore'
sh 'mkdir -p config/keystore'
sh 'cp $keystore config/keystore/'
}
script {
sh 'bundle exec fastlane build_staging'
}
}
}
stage('Parallel Stage') {
failFast true
parallel {
stage('Test') {
steps {
script {
sh 'bundle exec fastlane unit_test'
}
}
}
stage('Check') {
steps {
script {
sh 'bundle exec fastlane check'
}
}
}
}
}
stage('Deploy') {
when { expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' } }
steps {
script {
sh 'echo deploy'
}
}
}
stage('Production') {
when { branch pattern: "release(-v.+)?", comparator: "REGEXP"}
steps {
script {
// Copy release keystore to workspace
withCredentials([file(credentialsId: 'keystore-release', variable: 'keystore')]) {
sh 'rm -rf config/keystore'
sh 'mkdir -p config/keystore'
sh 'cp $keystore config/keystore/'
}
sh 'bundle exec fastlane build_prod'
}
}
}
}
post {
success {
dir("${params.APP_BUILD_FOLDER}") {
echo 'Archiving APKs...'
archiveArtifacts artifacts: "**/*.apk"
echo 'Archiving Mappings...'
archiveArtifacts artifacts: "**/mapping.txt", allowEmptyArchive: true
echo 'Archiving Reporters...'
archiveArtifacts artifacts: 'reports/**'
}
}
cleanup {
cleanWs()
}
}
}