forked from Microservice-crew/5TWIN4-G3-projet2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
130 lines (114 loc) · 3.74 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
pipeline {
agent any
environment {
IMAGE_TAG = "${env.BUILD_NUMBER}"
}
tools{
maven 'M2_HOME'
}
stages {
stage('Chekout GIT'){
steps {
echo 'Pulling...'
git branch: 'master' ,
url : 'https://github.com/Microservice-crew/5TWIN4-G3-projet2.git',
credentialsId: 'gits'
}
}
stage('MVN CLEAN'){
steps{
sh 'mvn clean';
}
}
stage('MVN COMPILE'){
steps{
sh 'mvn compile';
}
}
stage('MVN TEST'){
steps{
sh 'mvn clean test';
}
}
stage('JaCoCo Reports') {
steps {
sh 'mvn jacoco:report'
}
}
stage("Build") {
steps {
sh 'mvn install -DskipTests=true'
}
}
stage('MVN SONARQUBE') {
steps {
sh 'mvn sonar:sonar -Dsonar.login=admin -Dsonar.password=sonar -Dmaven.test.skip=true';
}
}
stage('Nexus Deploy ') {
steps {
nexusArtifactUploader artifacts: [
[
artifactId: 'kaddem',
classifier: '',
file: 'target/kaddem.jar',
type: 'jar'
]
],
credentialsId: 'nexus3',
groupId: 'tn.esprit.spring',
nexusUrl: 'localhost:8081',
nexusVersion: 'nexus3',
protocol: 'http',
repository: 'kaddem',
version: '0.0.1-SNAPSHOT'
}
}
stage('Build backend docker image') {
steps {
sh 'docker build -t $DOCKERHUB_USERNAME/arijhajji-5twin4-g3-kaddem:$IMAGE_TAG .'
}
}
// stage('Build frontend docker image') {
// steps {
// dir('Kaddem_FrontEnd') {
// sh 'docker build -t $DOCKERHUB_USERNAME/arijhajji-5twin4-g3-kaddemfront:$IMAGE_TAG .'
// }
// }
// }
stage('Push images to Dockerhub') {
steps{
script{
sh 'docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD'
sh 'docker push $DOCKERHUB_USERNAME/arijhajji-5twin4-g3-kaddem:$IMAGE_TAG'
// sh 'docker push $DOCKERHUB_USERNAME/arijhajji-5twin4-g3-kaddemfront:$IMAGE_TAG'
}
}
}
stage("Docker Compose ") {
steps {
echo "Docker compose"
sh'docker compose down'
sh 'docker compose up -d'
}
}
}
post {
always {
script {
currentBuild.result = currentBuild.currentResult
}
emailext subject: "Pipeline Status ${currentBuild.result}: ${currentBuild.projectName}",
body: """<html>
<body>
<p>Dear Team,</p>
<p>The pipeline for project <strong>${currentBuild.projectName}</strong> has completed with the status: <strong>${currentBuild.result}</strong>.</p>
<p>Thank you,</p>
<p>Your Jenkins Server</p>
</body>
</html>""",
to: '[email protected]',
mimeType: 'text/html'
}
}
}