forked from EdgeApp/edge-react-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
165 lines (156 loc) · 4.83 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
def build (platform) {
sh "mkdir -p buildnum temp"
// Copy the previous build num
try {
sh "cp ./buildnum/${platform}.json ./${platform}/buildnum.json"
} catch(err) {
println err
}
sh "node ./deploy.js edge ${platform} ${BRANCH_NAME}"
// Save the build num after a successful build
sh "cp ./${platform}/buildnum.json ./buildnum/${platform}.json"
// Add the build num and the platform to the description
def buildnum = readJSON file: "./buildnum/${platform}.json"
currentBuild.description += "\n${platform}-${buildnum.buildNum}"
}
pipeline {
agent any
tools {
nodejs "stable"
}
options {
timestamps()
skipDefaultCheckout true
}
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')
}
environment {
LC_CTYPE = 'en_US.UTF-8'
}
stages {
stage("Clean the workspace and checkout source") {
steps {
deleteDir()
checkout scm
}
}
stage ("Get version and build number") {
steps {
// Import the buildnums from previous build
copyArtifacts projectName: "${JOB_NAME}", selector: lastCompleted(), optional: true
// Fix version for branchs that are not "master" or "develop"
script {
def packageJson = readJSON file: "./package.json"
if (
BRANCH_NAME != "develop" &&
BRANCH_NAME != "master" &&
BRANCH_NAME != "test-feta" &&
BRANCH_NAME != "test-gouda" &&
BRANCH_NAME != "test-paneer" &&
BRANCH_NAME != "test" &&
BRANCH_NAME != "yolo"
) {
def cleanBranch = BRANCH_NAME.replaceAll('/', '-')
packageJson.version = "${packageJson.version}-${cleanBranch}".inspect()
writeJSON file: "./package.json", json: packageJson
}
def description = "[version] ${packageJson.version}"
if (BRANCH_NAME == "develop") description += "-d"
currentBuild.description = description
}
}
}
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"
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 "npm run cover"
}
}
stage ("Build") {
when {
anyOf {
branch 'develop'
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 {
build("ios")
}
}
stage("android") {
when { equals expected: true, actual: params.ANDROID_BUILD }
steps {
build("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',
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: "buildnum/", 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."
}
}
}