-
Notifications
You must be signed in to change notification settings - Fork 0
/
PiplineJenkins
150 lines (133 loc) · 4.19 KB
/
PiplineJenkins
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
pipeline {
agent any
tools {
maven 'M2_HOME'
}
stages {
stage('Checkout Git repository') {
steps {
echo 'Pulling ';
git branch: 'Aziz-Ben-Ismail-Universite', credentialsId: '50149f68-5226-4b9f-acb4-c0b99e149e50', url: 'https://github.com/DevOpsKaddem-G1/5TWIN6-G1-KADDEM-DevOps.git';
}
}
stage('Status Mysql') {
steps {
script {
sh 'sudo systemctl start mysql'
}
}
}
stage('Maven Clean Compile') {
steps {
sh 'mvn clean'
echo 'Running Maven Compile'
sh 'mvn compile'
}
}
stage('Tests - JUnit/Mockito') {
steps {
sh 'mvn test'
}
}
stage('Build package') {
steps {
sh 'mvn package'
}
}
stage('Maven Install') {
steps {
sh 'mvn install'
}
}
stage('Rapport JaCoCo') {
steps {
sh 'mvn test'
sh 'mvn jacoco:report'
}
}
stage('JaCoCo coverage report') {
steps {
step([$class: 'JacocoPublisher',
execPattern: '**/target/jacoco.exec',
classPattern: '**/classes',
sourcePattern: '**/src',
exclusionPattern: '*/target/**/,**/*Test*,**/*_javassist/**'
])
}
}
stage("SonarQube Analysis") {
steps {
withSonarQubeEnv('SonarQubeBenIsmail') {
sh 'mvn sonar:sonar'
}
}
}
stage('Deploy to Nexus') {
steps {
sh 'mvn deploy'
}
}
stage('Build Docker Image (Spring Part)') {
steps {
script {
sh 'sudo chmod 666 /var/run/docker.sock'
def dockerImage=docker.build("azizbenismail/kaddem:9")
}
}
}
stage('Push Docker Image to DockerHub') {
steps {
script {
withCredentials([string(credentialsId: 'dockerhubpwd', variable: 'dockerpwd')]) {
sh '''
docker login -u azizbenismail -p "$dockerpwd"
docker push azizbenismail/kaddem:9
'''
}
}
}
}
stage('Docker compose (FrontEnd BackEnd MySql)') {
steps {
script {
sh 'sudo systemctl stop mysql'
sh 'docker-compose up -d'
}
}
}
stage('Monitoring Services G/P') {
steps {
script {
sh 'docker start e76185fde1d4'
}
}
}
stage('Email Notification') {
steps{
// mail bcc: '', body: '''The pipeline has completed successfully. No action required.
// ''', cc: '', from: '', replyTo: '', subject: 'Succès de la pipeline DevOps Project KaddemUniversite BenIsmail', to: 'mohamedaziz.benismail@esprit.tn'
mail bcc: '', body: '''Stage: GIT Pull
- Pulling from Git...
Stage: Maven Clean Compile
- Building Spring project...
Stage: Test - JUNIT/MOCKITO
- Testing Spring project...
Stage: JaCoCo Report
- Generating JaCoCo Coverage Report...
Stage: SonarQube Analysis
- Running Sonarqube analysis...
Stage: Deploy to Nexus
- Deploying to Nexus...
Stage: Build Docker Image
- Building Docker image for the application...
Stage: Push Docker Image
- Pushing Docker image to Docker Hub...
Stage: Docker Compose
- Running Docker Compose...
Stage: Monitoring Services G/P
- Starting Prometheus and Grafana...
Final Report: The pipeline has completed successfully. No action required''', cc: '', from: '', replyTo: '', subject: 'Succès de la pipeline DevOps Project KaddemUniversite BenIsmail', to: 'mohamedaziz.benismail@esprit.tn'
}
}
}
}