-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile
More file actions
45 lines (40 loc) · 1.23 KB
/
Jenkinsfile
File metadata and controls
45 lines (40 loc) · 1.23 KB
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
#! groovy
library 'pipeline-library'
ansiColor('xterm') {
node('alfred') {
// git checkout stages
stage('Checkout') {
checkout scm
}
try {
// skip double builds on branch pushes
if (!env.BRANCH_NAME.startsWith('PR-') && env.BRANCH_NAME != 'master') {
currentBuild.result = 'SUCCESS'
return
}
// docker initialization
stage('Docker Setup') {
dockerStart()
}
// shorthand container execution
def exec = { command ->
sh 'docker run -i --rm ' +
'-v $HOME/.npm:/root/.npm ' + // mount the npm cache directories
'-v $WORKSPACE:/build ' + // mount the build workspace
'-w /build ' + // set the working directory
'node:lts ' + // use the latest node LTS
command // add the custom commands
};
// main builds
stage('Build') {
exec('npm install')
exec('npm test')
exec('bin/lexus-spec bundle dev')
}
} finally {
// stop all spare docker containers just in case
sh 'docker stop $(docker ps -aq) 2> /dev/null || true'
sh 'docker container prune -f'
}
}
}