-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
146 lines (130 loc) · 3.31 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
node('lisk-nano-01'){
lock(resource: "lisk-nano-01", inversePrecedence: true) {
stage ('Cleanup Orphaned Processes') {
try {
sh '''
# Clean up old processes
cd ~/lisk-test-nano
bash lisk.sh stop_node
pkill -f selenium -9 || true
pkill -f Xvfb -9 || true
rm -rf /tmp/.X0-lock || true
pkill -f webpack -9 || true
'''
} catch (err) {
currentBuild.result = 'FAILURE'
milestone 1
error('Stopping build, installation failed')
}
}
stage ('Prepare Workspace') {
try {
deleteDir()
checkout scm
} catch (err) {
currentBuild.result = 'FAILURE'
milestone 1
error('Stopping build, Checkout failed')
}
}
stage ('Start Lisk Core') {
try {
sh '''#!/bin/bash
cd ~/lisk-test-nano
bash lisk.sh rebuild -f /home/lisk/lisk-test-nano/blockchain_explorer.db.gz
'''
} catch (err) {
currentBuild.result = 'FAILURE'
milestone 1
error('Stopping build, Lisk Core failed to start')
}
}
stage ('Install npm dependencies') {
try {
sh '''#!/bin/bash
npm install
# Build nano
cd $WORKSPACE
npm install
'''
} catch (err) {
currentBuild.result = 'FAILURE'
milestone 1
error('Stopping build, npm install failed')
}
}
stage ('Run Eslint') {
try {
sh '''
cd $WORKSPACE
npm run eslint
'''
} catch (err) {
currentBuild.result = 'FAILURE'
error('Stopping build, Eslint failed')
}
}
stage ('Build Nano') {
try {
sh '''#!/bin/bash
# Add coveralls config file
cp ~/.coveralls.yml-nano .coveralls.yml
# Run Build
npm run build
'''
} catch (err) {
currentBuild.result = 'FAILURE'
milestone 1
error('Stopping build, Nano build failed')
}
}
stage ('Run Tests') {
try {
sh '''
export ON_JENKINS=true
# Run test
cd $WORKSPACE
npm run test
# Submit coverage to coveralls
cat coverage/*/lcov.info | coveralls -v
'''
} catch (err) {
currentBuild.result = 'FAILURE'
error('Stopping build, Test suite failed')
}
}
stage ('Start Dev Server and Run Tests') {
try {
sh '''
# Run Dev build and Build
cd $WORKSPACE
export NODE_ENV=
npm run dev &> .lisk-nano.log &
sleep 30
# End to End test configuration
export DISPLAY=:99
Xvfb :99 -ac -screen 0 1280x1024x24 &
./node_modules/protractor/bin/webdriver-manager update
# Run End to End Tests
npm run e2e-test
cd ~/lisk-test-nano
bash lisk.sh stop_node
pkill -f selenium -9 || true
pkill -f Xvfb -9 || true
rm -rf /tmp/.X0-lock || true
pkill -f webpack -9 || true
# Cleanup - delete all files on success
cd $WORKSPACE
rm -rf *
'''
} catch (err) {
currentBuild.result = 'FAILURE'
milestone 1
error('Stopping build, End to End Test suite failed')
}
}
stage ('Set milestone') {
milestone 1
}
}
}