forked from jenkins-infra/plugin-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
59 lines (51 loc) · 1.08 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
pipeline {
environment {
GET_CONTENT = "true"
NODE_ENV = "production"
TZ = "UTC"
}
agent {
label 'docker&&linux'
}
options {
timeout(time: 60, unit: 'MINUTES')
ansiColor('xterm')
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '5')
}
stages {
stage('NPM Install') {
steps {
runDockerCommand('node:14.17', 'npm ci')
}
}
stage('Build Production') {
steps {
runDockerCommand('node:14.17', 'npm run build')
}
}
stage('Check build') {
steps {
sh 'test -e public/index.html || exit 1'
}
}
stage('Lint and Test') {
steps {
runDockerCommand('node:14.17', 'npm run lint')
runDockerCommand('node:14.17', 'npm run test')
}
}
}
}
def runDockerCommand(image, cmd) {
sh """
docker run \
--network host \
--rm -e GET_CONTENT \
-w "\$PWD" \
-e HOME="\$PWD" \
-v "\$PWD:\$PWD" \
-u \$(id -u):\$(id -g) \
$image \
$cmd
"""
}