-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
75 lines (66 loc) · 1.88 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
pipeline {
agent any
stages {
stage('Clean Workspace') {
steps {
deleteDir()
}
}
stage('gitCheckout') {
steps {
script {
if (fileExists('.git')) {
sh 'git reset --hard'
sh 'git clean -fd'
sh 'git pull origin main'
} else {
git branch: 'main', url: 'https://github.com/andoniainalahatra/Elecdis_CSMS_OCPP_1_6-FrontEnd.git', credentialsId: 'github-credentials-id'
}
}
}
}
stage('Install dependencies') {
steps {
sh 'npm install'
}
}
stage('Build') {
steps {
sh 'npm run build'
}
}
stage('Cleanup Docker') {
steps {
sh '''
docker stop my-nginx-app || true
docker rm -f my-nginx-app || true
docker rmi -f my-nginx-app || true
'''
}
}
stage('Run Docker') {
steps {
sh 'docker build -t my-app .'
sh 'docker run -d -p 80:80 --name my-nginx-app my-app'
}
}
}
post {
success {
emailext (
body: 'Build completed successfully.',
subject: 'Build Success Notification',
to: 'kevinrakoto77@gmail.com',
attachLog: true
)
}
failure {
emailext (
body: 'The build has failed.',
subject: 'Build Failure Notification',
to: 'kevinrakoto77@gmail.com',
attachLog: true
)
}
}
}