forked from rajeshvasamsetty/nexus-jenkins-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_org
110 lines (108 loc) · 3.32 KB
/
Jenkinsfile_org
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
#!groovy
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
}
agent any
stages {
stage('Build') {
steps {
catchError {
sh '''
SBI/build.sh
'''
}
}
post {
success {
echo 'Build stage successful'
}
failure {
echo 'Compile stage failed'
error('Build is aborted due to failure of build stage')
}
}
}
stage('Test') {
steps {
catchError {
sh '''
SBI/test.sh
'''
}
}
post {
success {
echo 'Test stage successful'
}
failure {
echo 'Test stage failed'
error('Test is aborted due to failure of Test stage')
}
}
}
stage('Container Build') {
steps {
catchError {
sh '''
SBI/dockerize.sh
'''
}
}
post {
success {
echo 'Docker image build stage successful'
}
failure {
echo 'Docker image build stage failed'
error('Docker build is aborted due to failure of dockerize stage')
}
}
}
}
post {
always {
script {
currentBuild.result = currentBuild.currentResult
sh '''
if [ -f build_fail.log ];then
tail -50 build_fail.log >> build_fail.txt && rm -f build_fail.log && mv build_fail.txt build_fail.log && \
rm -f build_fail.log-txt* && unix2dos build_fail.log
fi
'''
}
}
fixed {
emailext (attachLog: true, body: "${currentBuild.result}: ${BUILD_URL}", //compressLog: true,
subject: "Jenkins build back to normal: ${currentBuild.fullDisplayName}",
// recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']],
to: '[email protected]')
}
failure {
script {
if (fileExists('build_fail.log')) {
emailext (attachmentsPattern: 'build_fail.log',
body: "${currentBuild.result}: ${BUILD_URL}", //compressLog: true,
subject: "Build failed in Jenkins: ${currentBuild.fullDisplayName}",
// : recipientProviders[[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']],
to: '[email protected]')
}else
{
emailext (attachLog: true, //attachmentsPattern: 'build_fail.log',
body: "${currentBuild.result}: ${BUILD_URL}", //compressLog: true,
subject: "Build failed in Jenkins: ${currentBuild.fullDisplayName}",
// recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']],
to: '[email protected]')
}
}
}
unstable {
// notify users when the Pipeline unstable
emailext (attachLog: true, body: "${currentBuild.result}: ${BUILD_URL}", //compressLog: true,
subject: "Unstable Pipeline: ${currentBuild.fullDisplayName}",
// recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']],
to: '[email protected]')
}
}
}