This repository has been archived by the owner on Jun 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
/
Jenkinsfile
113 lines (113 loc) · 2.7 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
/*
* Copyright © 2018 Lisk Foundation
*
* See the LICENSE file at the top-level directory of this distribution
* for licensing information.
*
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation,
* no part of this software, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE file.
*
* Removal or modification of this copyright notice is prohibited.
*
*/
@Library('lisk-jenkins') _
pipeline {
agent { node { label 'lisk-elements' } }
stages {
stage('Cancel previous running PR') {
steps {
script{
if (env.CHANGE_ID) {
// This is a Pull Request
cancelPreviousBuild()
}
}
}
}
stage('Install dependencies') {
steps {
script {
cache_file = restoreCache("package.json")
}
nvm(getNodejsVersion()) {
sh 'npm install --verbose'
}
script {
saveCache(cache_file, './node_modules', 10)
sh '''
if [ ! -f "/home/lisk/.cache/Cypress/$(jq -r .devDependencies.cypress ./packages/lisk-constants/package.json)/Cypress/Cypress" ]; then
./packages/lisk-constants/node_modules/.bin/cypress install --force
fi
'''
}
}
}
stage('Build') {
steps {
nvm(getNodejsVersion()) {
sh 'npm run build'
}
}
}
stage('Run lint') {
steps {
ansiColor('xterm') {
nvm(getNodejsVersion()) {
sh 'npm run lint'
}
}
}
}
stage('Run tests') {
steps {
ansiColor('xterm') {
nvm(getNodejsVersion()) {
sh 'npm run test'
}
}
}
}
stage('Run node tests') {
steps {
ansiColor('xterm') {
nvm(getNodejsVersion()) {
sh 'npm run test:node'
}
}
}
}
stage('Run browser tests') {
steps {
nvm(getNodejsVersion()) {
sh '''
npm run build:browsertest
npm run test:browser
'''
}
}
}
}
post {
success {
script {
build_info = getBuildInfo()
liskSlackSend('good', "Recovery: build ${build_info} was successful.")
}
deleteDir()
githubNotify context: 'continuous-integration/jenkins/lisk-elements', description: 'The build passed.', status: 'SUCCESS'
}
failure {
script {
build_info = getBuildInfo()
liskSlackSend('danger', "Build ${build_info} failed (<${env.BUILD_URL}/console|console>, <${env.BUILD_URL}/changes|changes>)\n")
}
archiveArtifacts allowEmptyArchive: true, artifacts: 'cypress/screenshots/'
githubNotify context: 'continuous-integration/jenkins/lisk-elements', description: 'The build failed.', status: 'FAILURE'
}
aborted {
githubNotify context: 'continuous-integration/jenkins/lisk-elements', description: 'The build was aborted.', status: 'ERROR'
}
}
}