-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathJenkinsfile
88 lines (77 loc) · 2.31 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
pipeline {
agent any
tools {
maven 'Maven'
jdk 'java17'
git 'git'
}
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/Mouslih1/social-network-microservice'
}
}
stage('Build') {
steps {
script {
def microservices = ['discovery','geteway', 'media-service','auth-service', 'Friend-service', 'interaction-service', 'User-service']
microservices.each { service ->
dir(service) {
if (isUnix()) {
sh 'mvn clean install'
} else {
bat 'mvn clean install'
}
}
}
}
}
}
stage('Docker') {
steps {
script {
if (isUnix()) {
sh 'docker-compose -f Docker-compose.yml up -d --build'
} else {
bat 'docker-compose -f Docker-compose.yml up -d --build'
}
}
}
}
stage('Report') {
steps {
script {
if (isUnix()) {
sh 'mvn clean site'
} else {
bat 'mvn clean site'
}
}
}
}
stage('Push to Docker Hub') {
steps {
script {
if (isUnix()) {
sh 'docker login -u marouane01 -p Mouslih2001@'
sh 'docker-compose -f Docker-compose.yml push'
} else {
bat 'docker login -u marouane01 -p Mouslih2001@'
bat 'docker-compose -f Docker-compose.yml push'
}
}
}
}
}
post {
success {
echo 'Build succeeded!'
}
failure {
echo 'Build failed!'
}
unstable {
echo 'Build unstable!'
}
}
}