-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
63 lines (61 loc) · 1.93 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
pipeline {
agent any
stages {
stage('Git Checkout') {
steps {
checkout scmGit(branches: [[name: '*/Vu']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/NhatLe2002/SecurityGateApv_BE.git']])
}
}
stage('Docker Build') {
agent any
steps {
sh 'docker build -t apv_be -f SecurityGateApv.WebApi/Dockerfile .'
}
}
stage('Docker Check Exist Container') {
agent any
steps {
script{
def inspectExitCode = sh script: "docker inspect apvsecurity", returnStatus: true
if (inspectExitCode == 0) {
sh "docker stop apvsecurity"
sh "docker rm apvsecurity"
}
else{
}
}
}
}
stage('Docker deploy') {
agent any
steps {
sh 'docker run -d --name "apvsecurity" --restart=always -p 8081:8080 apv_be'
}
}
stage('Docker Delete Dangling Image') {
agent any
steps {
sh "docker image prune -f"
}
}
}
post
{
always{
emailext (
subject: "Pipeline Status: ${BUILD_NUMBER}",
body: '''<html>
<body>
<p>Build Status: ${BUILD_STATUS}</p>
<p>Build Status: ${BUILD_NUMBER}</p>
<p>CheckThe : <a href="${BUILD_URL}">console output</a>.</p>
<body>
</html>''',
to: "[email protected]",
from: "[email protected]",
replyTo: "[email protected]",
mimeType: "text/html"
)
}
}
}