-
Notifications
You must be signed in to change notification settings - Fork 261
/
Jenkinsfile
179 lines (161 loc) · 5.38 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
def global = [:]
def preBuildStages(String stageName, versionFile) {
stage("${stageName}: preBuildStages") {
echo "Running on ${env.NODE_NAME}"
deleteDir()
checkout scm
def versionString = "${versionFile.branch} ${versionFile.version} (${versionFile.build})"
echo "versionString: ${versionString}"
writeJSON file: './release-version.json', json: versionFile
currentBuild.description = versionString
sh 'yarn'
// Import the settings files
withCredentials([file(credentialsId: 'githubSshKey', variable: 'id_github')]) {
sh "cp ${id_github} ./id_github"
}
sh "node -r sucrase/register ./scripts/secretFiles.ts ${BRANCH_NAME} ${SECRET_FILES}"
sh "node -r sucrase/register ./scripts/patchFiles.ts edge ${BRANCH_NAME}"
// Pick the new build number and version from git:
sh 'node -r sucrase/register ./scripts/updateVersion.ts'
sh 'yarn prepare'
}
}
def preTest(String stageName) {
stage("${stageName}: preTest") {
sh 'yarn test --ci'
}
}
def buildProduction(String stageName) {
stage("Build ${stageName}") {
echo "Running on ${env.NODE_NAME}"
if (env.BRANCH_NAME in ['develop', 'staging', 'master', 'beta', 'test-cheddar', 'test-feta', 'test-gouda', 'test-halloumi', 'test-paneer', 'test', 'testMaestro', 'yolo']) {
if (stageName == 'ios' && params.IOS_BUILD) {
sh 'npm run prepare.ios'
sh "node -r sucrase/register ./scripts/deploy.ts edge ios ${BRANCH_NAME}"
}
if (stageName == 'android' && params.ANDROID_BUILD) {
sh "node -r sucrase/register ./scripts/deploy.ts edge android ${BRANCH_NAME}"
}
}
}
}
def buildMaestro(String stageName) {
stage("Build Maestro ${stageName}") {
if (env.BRANCH_NAME in ['develop', 'staging', 'master', 'beta', 'testMaestro']) {
if (stageName == 'ios' && params.IOS_BUILD_MAESTRO) {
echo "Running on ${env.NODE_NAME}"
sh 'npm run prepare.ios'
sh "node -r sucrase/register ./scripts/deploy.ts edge ios ${BRANCH_NAME} maestro"
}
if (stageName == 'android' && params.ANDROID_BUILD_MAESTRO) {
echo "Running on ${env.NODE_NAME}"
sh "node -r sucrase/register ./scripts/deploy.ts edge android ${BRANCH_NAME} maestro"
}
}
}
}
pipeline {
agent none
tools {
jdk '17'
nodejs '22'
}
options {
timestamps()
skipDefaultCheckout true
overrideIndexTriggers false
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '10')
disableConcurrentBuilds()
}
triggers {
pollSCM('H/2 * * * *')
}
parameters {
booleanParam(name: 'ANDROID_BUILD', defaultValue: true, description: 'Build an Android version')
booleanParam(name: 'ANDROID_BUILD_MAESTRO', defaultValue: true, description: 'Build an Android Maestro version')
booleanParam(name: 'IOS_BUILD', defaultValue: true, description: 'Build an iOS version')
booleanParam(name: 'IOS_BUILD_MAESTRO', defaultValue: true, description: 'Build an iOS simulator Maestro version')
booleanParam(name: 'VERBOSE', defaultValue: false, description: 'Complete build log output')
}
environment {
LC_CTYPE = 'en_US.UTF-8'
DISABLE_XCPRETTY = "${params.VERBOSE}"
}
stages {
stage('Preparation') {
agent { label 'ios-build || android-build' }
steps {
script {
echo "Running on ${env.NODE_NAME}"
deleteDir()
checkout scm
// Import the settings files
withCredentials([file(credentialsId: 'githubSshKey', variable: 'id_github')]) {
sh "cp ${id_github} ./id_github"
}
// Use npm to install Sucrase globally
sh 'yarn add --dev sucrase'
sh "node -r sucrase/register ./scripts/gitVersionFile.ts ${BRANCH_NAME}"
def versionFile = readJSON file: './release-version.json'
global.versionFile = versionFile
echo "Created version file: ${global.versionFile.branch} ${global.versionFile.version} (${global.versionFile.build})"
}
}
}
stage('Parallel Stage') {
parallel {
stage('IOS Build') {
agent { label 'ios-build' }
steps {
script {
preBuildStages('IOS', global.versionFile)
preTest('IOS')
buildProduction('ios')
}
}
}
stage('IOS Maestro Build') {
agent { label 'ios-build-sim' }
steps {
script {
preBuildStages('IOS Maestro', global.versionFile)
preTest('IOS Maestro')
buildMaestro('ios')
}
}
}
stage('Android Build') {
agent { label 'android-build' }
steps {
script {
preBuildStages('Android', global.versionFile)
preTest('Android')
buildProduction('android')
}
}
}
stage('Android Maestro Build') {
agent { label 'android-build' }
steps {
script {
preBuildStages('Android', global.versionFile)
preTest('Android')
buildMaestro('android')
}
}
}
}
}
}
post {
success {
echo 'The force is strong with this one'
}
unstable {
echo 'Do or do not there is no try'
}
failure {
echo 'The dark side I sense in you.'
}
}
}