-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
43 lines (42 loc) · 1.5 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
pipeline {
agent any
stages {
stage ('Compile') {
steps {
echo '***************** Compile Source Code ***************'
bat 'mvn clean package install -DskipTests'
}
}
stage ('Test') {
steps {
echo '****************** Run Tests ******************'
bat 'mvn test'
}
}
stage('Build'){
steps{
echo '****************** Build Docker Image ****************'
bat 'docker build -t football-service:1.0.0 --no-cache -f Dockerfile .'
}
}
stage('Pre-Deploy-check') {
steps {
echo '****************************** Remove running container ***************************************'
script {
//containerID = bat (returnStdout: true, script:'docker container ls --all | grep -w c_football-service | awk "{print $1}"')
containerID = powershell(returnStdout: true, script:'docker ps -af name=c_football-service --format "{{.ID}}"')
if(containerID) {
bat "docker stop ${containerID}"
bat "docker rm -f ${containerID}"
}
}
}
}
stage('Deploy'){
steps{
echo '****************** Deploy Docker Image *************************'
bat 'docker container run --name c_football-service -d -p 8080:8080 -t football-service:1.0.0'
}
}
}
}