forked from terryvdgriend/workshop-cicd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
82 lines (82 loc) · 2.4 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
pipeline {
agent {
label 'master'
}
stages {
stage('Prepare') {
agent {
docker { image 'node:alpine' }
}
steps {
dir('code/backend') {
sh 'npm install'
}
dir('code/frontend') {
sh 'npm install'
}
}
}
stage('Build') {
agent {
docker { image 'node:alpine' }
}
steps {
dir('code/frontend') {
sh 'npm run build'
}
}
}
stage('Static Analysis') {
agent {
docker { image 'node:alpine' }
}
steps {
dir('code/backend') {
sh 'npm run lint'
}
dir('code/frontend') {
sh 'npm run lint'
}
}
}
stage('Unit Test') {
agent {
docker { image 'node:alpine' }
}
steps {
dir('code/backend') {
sh 'npm run test'
}
}
}
// stage('e2e Test') {
// steps {
// dir('ci/code') {
// sh 'docker-compose -f docker-compose-e2e.yml build'
// sh 'docker-compose -f docker-compose-e2e.yml up -d frontend backend'
// script {
// sh 'docker-compose -f docker-compose-e2e.yml up e2e'
// status_code = sh ( script: "docker inspect code_e2e_1 --format='{{.State.ExitCode}}'", returnStdout: true).trim();
// if (status_code == '1'){
// error('e2e test failed.')
// }
// }
// }
// }
// post {
// always {
// dir('ci/code') {
// sh 'docker-compose -f docker-compose-e2e.yml down --rmi=all -v'
// }
// }
// }
// }
stage('Deploy') {
steps {
dir('ci/code') {
sh 'docker-compose -f docker-compose.yml up -d'
}
}
}
}
}