-
Notifications
You must be signed in to change notification settings - Fork 0
/
SIT223 6.groovy
110 lines (103 loc) · 3.21 KB
/
SIT223 6.groovy
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
pipeline {
agent any
environment {
DIRECTORY_PATH = 'C/Users/tomwalk/Documents/Uni/SIT223'
TESTING_ENVIRONMENT = 'Toms PC'
PRODUCTION_ENVIRONMENT = 'Tom'
}
stages {
stage('Build') {
steps {
script {
sh """
echo "fetch the source code from ${DIRECTORY_PATH}" >> build.log
echo "compile the code and generate any necessary artifacts" >> build.log
"""
}
}
post {
success {
emailext to: '[email protected]',
subject: 'Build status email',
body: 'Build was successful'
}
}
}
stage('Test') {
steps {
script {
sh """
echo "Running unit and integration tests..." >> build.log
"""
}
}
post {
success {
emailext to: '[email protected]',
subject: 'Unit and Integration Tests status email',
body: 'Testing was successful'
}
}
}
stage('Code Analysis') {
steps {
script {
sh """
echo "Checking code quality..." >> build.log
"""
}
}
}
stage('Security Scan') {
steps {
script {
sh """
echo "Running security scans..." >> build.log
"""
}
}
post {
success {
emailext to: '[email protected]',
subject: 'Security Scan Status',
body: 'Security Scan Successful'
}
failure {
emailext to: '[email protected]',
subject: 'Security Scan Status',
body: 'Security Scan failed'
}
}
}
stage('Integration Tests') {
steps {
script {
sh """
sleep 10
echo "Integration tests completed..." >> build.log
"""
}
}
}
stage('Deploy to Production') {
steps {
script {
sh """
echo "Deploying to ${PRODUCTION_ENVIRONMENT}..." >> build.log
"""
}
}
}
}
post {
always {
// Archive the log file generated during the pipeline execution
archiveArtifacts artifacts: 'build.log', allowEmptyArchive: true
// Send the email with the log file as an attachment
emailext body: 'Stage Complete. Please find the attached logs.',
subject: 'Build Logs',
to: '[email protected]',
attachmentsPattern: 'build.log'
}
}
}