-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
91 lines (82 loc) · 2.72 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
pipeline {
agent any
options {
ansiColor('xterm')
}
stages {
// stage('Download') {
// steps {
// // Get code from branch to test
// // This git command is using the Jenkins plugin. "git" here acts like "git checkout"
// git branch: 'main', url: 'https://github.com/david-fisher/320-S22-Track2.git'
// }
// }
// Install and close server if was open
stage('npm Setup') {
steps{
script{
try{
sh 'killall node'
}
catch(exe){
echo "Nothing to kill"
}
dir("front-end"){
script{
sh 'npm install'
}
}
}
}
}
//Check esLint compliance
stage('SyntaxCheck') {
steps{
dir("front-end") {
script {
try {
sh 'npx next lint --quiet'
}
catch(exc) {
error("It appears not all esLint rules have been met.") //Fail Jenkins build
}
// Don't actually know what this is supposed to do, found online:
// finally {
// step([$class: 'ArtifactArchiver', artifacts: 'app/build/reports/staticAnalysis/lint/', fingerprint: true])
// }
}
}
}
}
stage('Build'){ //Build the project so Cypress tests run faster
steps{
dir("front-end") {
script{
try{
sh 'npm run build'
}
catch(exe){
error("Building failed!")
}
}
}
}
}
stage('Cypress Tests'){ //Currenly running with dev. Eventually will use npm start
steps{
dir("front-end") {
script{
try{
sh 'npm run start & npx cypress run --config video=false -b chrome'
sh 'killall node' //Cleanup so server doesn't run forever
}
catch(exe){
sh 'killall node' //Cleanup so server doesn't run forever
error("Cypress test failed!")
}
}
}
}
}
}
}