-
Notifications
You must be signed in to change notification settings - Fork 261
/
Jenkinsfile
149 lines (139 loc) · 4.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
pipeline {
agent any
tools {
nodejs "stable"
}
options {
timestamps()
skipDefaultCheckout true
overrideIndexTriggers false
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '10')
disableConcurrentBuilds()
}
triggers {
pollSCM("H/5 * * * *")
}
parameters {
booleanParam(name: 'ANDROID_BUILD', defaultValue: true, description: 'Build an Android version')
booleanParam(name: 'IOS_BUILD', defaultValue: true, description: 'Build an iOS version')
booleanParam(name: 'VERBOSE', defaultValue: false, description: 'Complete build log output')
}
environment {
LC_CTYPE = 'en_US.UTF-8'
DISABLE_XCPRETTY = "${params.VERBOSE}"
}
stages {
stage("Clean the workspace and checkout source") {
steps {
deleteDir()
checkout scm
}
}
stage ("Get build number and version") {
steps {
// Install dependencies for the versioning script:
sh "npm i disklet cleaners sucrase"
// Copy release-version.json from the previous build:
copyArtifacts projectName: "${JOB_NAME}", selector: lastCompleted(), optional: true
// Pick the new build number and version:
sh "./scripts/updateVersion.js ${BRANCH_NAME}"
// Update our description:
script {
def versionFile = readJSON file: "./release-version.json"
currentBuild.description = "version: ${versionFile.version} (${versionFile.build})"
}
}
}
stage ("Load credentials") {
steps {
// Import the settings files
withCredentials([
file(credentialsId: "bfcc847f-213a-4de5-86a5-29b62b34c79d", variable: "deploy_config"),
file(credentialsId: "94c9f265-a991-432c-9bc4-b74a311f4063", variable: "GoogleService_Info"),
file(credentialsId: "f1ebd0b2-4e79-4bd4-a290-a3001604c1fc", variable: "google_services"),
file(credentialsId: "2b938625-9c20-4b64-8c24-ce27543402b6", variable: "edge_release_keystore"),
file(credentialsId: "05926db4-40f8-42ac-a761-be4e1186ec7a", variable: "env_json"),
]) {
sh "cp ${deploy_config} ./deploy-config.json"
sh "cp ${GoogleService_Info} ./GoogleService-Info.plist"
sh "cp ${google_services} ./google-services.json"
sh "mkdir -p ./keystores temp"
sh "cp ${edge_release_keystore} ./keystores/edge-release-keystore.jks"
sh "cp ${env_json} ./env.json"
}
}
}
stage ("Install dependencies") {
steps {
sh "yarn"
}
}
stage ("Test") {
steps {
sh "JEST_JENKINS=1 yarn cover --ci"
}
}
stage ("Build") {
when {
anyOf {
branch 'develop'
branch 'staging'
branch 'master'
branch 'test-feta'
branch 'test-gouda'
branch 'test-paneer'
branch 'test'
branch 'yolo'
}
}
stages {
stage("ios") {
when { equals expected: true, actual: params.IOS_BUILD }
steps {
sh "node ./deploy.js edge ios ${BRANCH_NAME}"
sh "./scripts/uploadSourcemaps.js ios"
}
}
stage("android") {
when { equals expected: true, actual: params.ANDROID_BUILD }
steps {
sh "node ./deploy.js edge android ${BRANCH_NAME}"
sh "./scripts/uploadSourcemaps.js android"
}
}
}
}
}
post {
always {
echo 'Trying to publish the test report'
junit healthScaleFactor: 100.0, testResults: '**/coverage/junit.xml', allowEmptyResults: true
echo 'Trying to publish the code coverage report'
cobertura(
coberturaReportFile: '**/coverage/cobertura-coverage.xml',
failUnhealthy: false,
failNoReports: false,
failUnstable: false,
onlyStable: false,
zoomCoverageChart: false,
conditionalCoverageTargets: '70, 0, 0',
lineCoverageTargets: '70, 0, 0',
methodCoverageTargets: '70, 0, 0',
maxNumberOfBuilds: 0,
sourceEncoding: 'ASCII'
)
// Archiving the buildnums for future builds
archiveArtifacts artifacts: "release-version.json", allowEmptyArchive: true
}
success {
echo "The force is strong with this one"
deleteDir()
}
unstable {
echo "Do or do not there is no try"
}
failure {
echo "The dark side I sense in you."
}
}
}