0% found this document useful (0 votes)
90 views4 pages

Pipeline Devops

The pipeline pulls code from a Git repository, builds a Spring project using Maven, runs tests, generates code coverage reports, performs a SonarQube analysis, deploys to Nexus, builds a Docker image, pushes the image to Docker Hub, runs Docker Compose, starts monitoring services with Prometheus and Grafana, and emails a summary report.

Uploaded by

Houssem kouki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views4 pages

Pipeline Devops

The pipeline pulls code from a Git repository, builds a Spring project using Maven, runs tests, generates code coverage reports, performs a SonarQube analysis, deploys to Nexus, builds a Docker image, pushes the image to Docker Hub, runs Docker Compose, starts monitoring services with Prometheus and Grafana, and emails a summary report.

Uploaded by

Houssem kouki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

pipeline {

agent any

environment {
DOCKERHUB_CREDENTIALS = credentials('dockerhub')
}

stages {
stage('GIT Pull') {
steps {
echo 'Pulling from Git ...'
// Utilisation de la branche 'houssem' depuis le référentiel Git
avec les informations d'identification 'accessGIT'
git branch: 'houssem', credentialsId: 'accessGIT', url:
'https://github.com/Housseem-Kouki/DevopsProject.git'
}
}

stage('Maven Clean Compile') {


steps {
echo 'Building Spring project...'
dir('DevOps_Project') {
sh 'mvn clean compile'
}
}
}

stage('Test - JUNIT/MOCKITO') {
steps {
echo 'Testing Spring project...'
dir('DevOps_Project') {
sh'docker start c36e35dd9cb9_mysqldata'
sh 'mvn test'
}
}
}

stage('JaCoCo Report') {
steps {
echo 'Generating JaCoCo Coverage Report...'
dir('DevOps_Project') {
// Génération du rapport de couverture JaCoCo
sh 'mvn jacoco:report'
}
}
}

stage('SonarQube Analysis') {
steps {
echo 'Sonarqube analysis'
dir('DevOps_Project') {
sh 'mvn sonar:sonar -Dsonar.login=admin -
Dsonar.password=sonar'
}
}
}
stage('Deploy to Nexus') {
steps {
echo 'Deploying to Nexus'
dir('DevOps_Project') {
// Déploiement vers le référentiel Nexus avec sa configuration
sh 'mvn deploy -DskipTests -DrepositoryId=deploymentRepo -e -X'
}
}
}

stage('Build Docker Image') {


steps {
echo 'Building Docker image for the application...'
script {
// Utilisation de la commande docker build pour construire l'image
dir('DevOps_Project') {
sh 'docker build -t devops_project .'
}
}
}

stage('Push Docker Image') {


steps {
script {
def dockerUsername = 'koukihoussem'
def dockerPassword = 'dockerhub'
sh "docker login -u $dockerUsername -p $dockerPassword"
dir('DevOps_Project') {
sh 'docker tag devops_project koukihoussem/devops_project:latest'
sh 'docker push koukihoussem/devops_project:latest'
}
}
}
}

stage('Docker Compose') {
steps {
dir('DevOps_Project') {
sh 'docker compose up -d'
sh 'docker compose ps'
}
}
}

stage('Monitoring Services G/P') {


steps {
dir('DevOps_Project') {
sh 'docker start prometheus'
sh 'docker start grafana'
}
}
}

stage('Email') {
steps {
script {
def emailBody = ""

// Append details from each stage


emailBody += "Build Status: ${currentBuild.result ?: 'SUCCESS'}\n\n"

// GIT Pull
emailBody += "Stage: GIT Pull\n"
emailBody += " - Pulling from Git...\n\n"

// Maven Clean Compile


emailBody += "Stage: Maven Clean Compile\n"
emailBody += " - Building Spring project...\n\n"

// Test - JUNIT/MOCKITO
emailBody += "Stage: Test - JUNIT/MOCKITO\n"
emailBody += " - Testing Spring project...\n\n"

// JaCoCo Report
emailBody += "Stage: JaCoCo Report\n"
emailBody += " - Generating JaCoCo Coverage Report...\n\n"

// SonarQube Analysis
emailBody += "Stage: SonarQube Analysis\n"
emailBody += " - Running Sonarqube analysis...\n\n"

// Deploy to Nexus
emailBody += "Stage: Deploy to Nexus\n"
emailBody += " - Deploying to Nexus...\n\n"

// Build Docker Image


emailBody += "Stage: Build Docker Image\n"
emailBody += " - Building Docker image for the application...\n\n"

// Push Docker Image


emailBody += "Stage: Push Docker Image\n"
emailBody += " - Pushing Docker image to Docker Hub...\n\n"

// Docker Compose
emailBody += "Stage: Docker Compose\n"
emailBody += " - Running Docker Compose...\n\n"

// Monitoring Services G/P


emailBody += "Stage: Monitoring Services G/P\n"
emailBody += " - Starting Prometheus and Grafana...\n\n"

// Email Notification
if (currentBuild.result == 'FAILURE') {
emailBody += "Final Report: The pipeline has failed. Please check
the logs and reports for more details.\n"
} else {
emailBody += "Final Report: The pipeline has completed
successfully. No action required.\n"
}

mail(
body: emailBody,
subject: currentBuild.result == 'FAILURE' ? "❌ Échec de la pipeline
DevOps Project" : "✅ Succès de la pipeline DevOps Project",
to: "houssem.kouki@esprit.tn"
)
}
}
}

//fermeture stages
}

//post

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy