-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
99 lines (87 loc) · 2.62 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
pipeline {
agent any
tools {
nodejs 'node'
}
environment {
NPM_CONFIG_CACHE = "${WORKSPACE}/.npm"
FrontEndEnv = credentials('FrontEnv')
BackEndEnv = credentials('BackEnv')
}
stages {
stage('Clean Workspace Starting') {
steps {
cleanWs()
}
}
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/wizelineacademy/itesm-socioformador-ago-dec-2023-team-01.git'
}
}
stage('set dot envs'){
steps {
sh 'cp -f $FrontEndEnv frontend'
sh 'cp -f $BackEndEnv backend'
}
}
stage('Stop pm2 processes') {
steps {
sh 'pm2 stop 0 1'
}
}
stage('Build Frontend') {
steps {
dir('frontend') {
sh 'npm install'
sh 'npm run build'
}
}
}
stage('Build Backend') {
steps {
dir('backend') {
sh 'npm install'
sh 'npx prisma migrate dev'
sh 'npx prisma generate'
}
}
}
stage('Run Tests') {
steps {
dir('backend/tests') {
script {
def testResult = sh(script: './run_tests.sh', returnStatus: true)
if (testResult != 0) {
echo "Tests failed."
/*
sh 'pm2 start 0 1'
currentBuild.result = 'FAILURE'
error "Tests failed. Aborting the pipeline."
*/
} else {
echo "Tests passed."
}
}
}
}
}
stage('Copy workspace') {
steps {
sh 'rm -rf /home/bitnami/htdocs/*'
sh 'mkdir -p /home/bitnami/htdocs/itesm-socioformador-ago-dec-2023-team-01/'
sh 'cp -r $WORKSPACE/* /home/bitnami/htdocs/itesm-socioformador-ago-dec-2023-team-01/'
}
}
stage('Start pm2 processes') {
steps {
sh 'pm2 start 0 1'
}
}
stage('Clean Workspace Ending') {
steps {
cleanWs()
}
}
}
}