forked from LiskArchive/lisk-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
152 lines (145 loc) · 3.33 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
@Library('lisk-jenkins') _
pipeline {
agent { node { label 'lisk-explorer' } }
environment {
LISK_CORE_VERSION = '1.3.1'
EXPLORER_PORT = "604$EXECUTOR_NUMBER"
LISK_HOST = 'localhost'
REDIS_DB = "$EXECUTOR_NUMBER"
REDIS_HOST = 'localhost'
}
stages {
stage ('Build dependencies') {
steps {
nvm(getNodejsVersion()) {
sh 'npm ci'
}
}
}
stage ('Run ESLint') {
steps {
nvm(getNodejsVersion()) {
sh 'npm run eslint'
}
}
}
stage ('Build bundles') {
steps {
nvm(getNodejsVersion()) {
sh 'npm run build'
}
}
}
stage ('Build candles') {
steps {
nvm(getNodejsVersion()) {
// marketwatcher needs to be enabled to builds candles
sh '''
redis-cli -n $REDIS_DB flushdb
grunt candles:build
'''
}
}
}
stage ('Start Lisk') {
steps {
dir('lisk') {
checkout([$class: 'GitSCM',
branches: [[name: "v${env.LISK_CORE_VERSION}" ]],
userRemoteConfigs: [[url: 'https://github.com/LiskHQ/lisk']]])
}
ansiColor('xterm') {
sh '''#!/bin/bash -xe
rm -rf $WORKSPACE/$BRANCH_NAME/
cp -rf $WORKSPACE/lisk/docker/ $WORKSPACE/$BRANCH_NAME/
cp $WORKSPACE/test/data/test_blockchain-explorer.db.gz $WORKSPACE/$BRANCH_NAME/dev_blockchain.db.gz
cd $WORKSPACE/$BRANCH_NAME
cp .env.development .env
sed -i -r -e '/ports:/,+2d' docker-compose.yml
# random port assignment
cat <<EOF >docker-compose.override.yml
version: "2"
services:
lisk:
ports:
- \\${ENV_LISK_HTTP_PORT}
- \\${ENV_LISK_WS_PORT}
EOF
ENV_LISK_VERSION="$LISK_CORE_VERSION" make coldstart
'''
// show some build-related info
sh '''
cd $WORKSPACE/$BRANCH_NAME
sha1sum dev_blockchain.db.gz
docker-compose config
docker-compose ps
'''
}
}
}
stage ('Start Explorer') {
steps {
nvm(getNodejsVersion()) {
sh '''
cd $WORKSPACE/$BRANCH_NAME
LISK_PORT=$( docker-compose port lisk 4000 |cut -d ":" -f 2 )
cd -
LISK_PORT=$LISK_PORT node app.js -p $EXPLORER_PORT &>/dev/null &
sleep 20
'''
}
}
}
stage ('Run API tests') {
steps {
nvm(getNodejsVersion()) {
sh '''
sed -i -r -e "s/6040/$EXPLORER_PORT/" test/node.js
npm run test
'''
}
}
}
// stage ('Run E2E tests') {
// steps {
// wrap([$class: 'Xvfb']) {
// nvm(getNodejsVersion()) {
// sh 'npm run test:e2e -- --params.baseURL http://localhost:$EXPLORER_PORT'
// }
// }
// }
// }
}
post {
success {
script {
if (currentBuild.result == null || currentBuild.result == 'SUCCESS') {
previous_build = currentBuild.getPreviousBuild()
if (previous_build != null && previous_build.result == 'FAILURE') {
build_info = getBuildInfo()
liskSlackSend('good', "Recovery: build ${build_info} was successful.")
}
}
}
}
failure {
script {
build_info = getBuildInfo()
liskSlackSend('danger', "Build ${build_info} failed (<${env.BUILD_URL}/console|console>, <${env.BUILD_URL}/changes|changes>)\n")
}
}
always {
dir("$WORKSPACE/$BRANCH_NAME/") {
ansiColor('xterm') {
sh 'docker-compose logs || true'
sh 'make mrproper'
}
}
junit 'xunit-report.xml'
archiveArtifacts artifacts: 'logs/*.log', allowEmptyArchive: true
dir('logs') {
deleteDir()
}
}
}
}