-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkinsfile
More file actions
58 lines (55 loc) · 2.13 KB
/
Copy pathjenkinsfile
File metadata and controls
58 lines (55 loc) · 2.13 KB
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
pipeline {
agent any
environment {
VENV_DIR = 'venv'
}
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/NoForcing/devops_tp_4.git'
}
}
stage('Setup') {
steps {
sh 'python3 -m venv venv' // Crée un environnement virtuel
sh './venv/bin/pip install -r requirements.txt' // Installe les dépendances
}
}
stage('Run Script') {
steps {
sh './venv/bin/python app.py' // Exécute le script Python
}
}
}
post {
always { // Exécuté à la fin, que le build réussisse ou échoue
script {
def jobName = env.JOB_NAME
def buildNumber = env.BUILD_NUMBER
def pipelineStatus = currentBuild.result ?: "UNKNOWN" // Maintenant, il est bien défini
//pipelineStatus="FAILURE"
def bannerColor = pipelineStatus.toUpperCase() == 'SUCCESS' ? "green" : "red"
def body = """
<html>
<body>
<div style="border: 4px solid ${bannerColor}; padding: 10px;">
<h2>${jobName} - Build ${buildNumber}</h2>
<div style="background-color:${bannerColor}; padding:10px;">
<h3 style="color: white;">Pipeline Status: ${pipelineStatus.toUpperCase()}</h3>
</div>
<p>Check the <a href="${env.BUILD_URL}">console output</a>.</p>
</div>
</body>
</html>"""
emailext(
subject: "${jobName} - Build ${buildNumber} - ${pipelineStatus.toUpperCase()}",
body: body,
to: 'jeanfabriceouffoue@gmail.com',
from: 'jeanfabriceouffoue2002@gmail.com',
replyTo: 'jeanfabriceouffoue2002@gmail.com',
mimeType: 'text/html'
)
}
}
}
}