-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathJenkinsfile
127 lines (90 loc) · 2.54 KB
/
Jenkinsfile
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
#!groovy
node {
try {
stage('Checkout source code') {
echo "Checking out source code"
checkout scm
}
stage('Print Env After source checkout') {
echo "Branch Name: ${env.BRANCH_NAME}"
echo "BUILD_NUMBER : ${env.BUILD_NUMBER}"
echo "BUILD_ID : ${env.BUILD_ID}"
echo "JOB_NAME: ${env.JOB_NAME}"
echo "BUILD_TAG : ${env.BUILD_TAG}"
echo "EXECUTOR_NUMBER : ${env.EXECUTOR_NUMBER}"
echo "NODE_NAME: ${env.NODE_NAME}"
echo "NODE_LABELS : ${env.NODE_LABELS}"
echo "WORKSPACE : ${env.WORKSPACE}"
echo "JENKINS_HOME : ${env.JENKINS_HOME}"
}
stage('Build') {
echo "Build Stage Starting"
sh "sudo pip install coveralls"
echo "Build Stage Finsihed"
}
stage('Unit-Test') {
echo "Unit Tests Starting"
sh "make test-unit CI_SERVER=jenkins"
echo "Unit Tests Finished"
}
stage('Component-Test') {
echo "Component Tests Starting"
sh "make test-component CI_SERVER=jenkins"
echo "Component Tests Finished"
}
stage('Directory-Script-Test') {
echo "Chekcking Directory and Shell scripting power"
echo "ls -a (first)"
sh "ls -a"
dir('ci_testing_python/app') {
echo "inside directory ci_testing_python/app"
echo "ls -a (seconds)"
sh "ls -a"
}
echo "ls -a (third)"
sh "ls -a"
}
}
catch (e) {
// If there was an exception thrown, the build failed
currentBuild.result = "FAILED"
throw e
}
finally {
// Success or failure, always send notifications
notifyBuild(currentBuild.result)
}
}
def notifyBuild(String buildStatus = 'STARTED') {
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESS'
// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '#${env.BUILD_NUMBER} of ${env.JOB_NAME}'"
def summary = "${subject} at (${env.BUILD_URL}/console)"
def details = """<p>STARTED: Job '#${env.BUILD_NUMBER} of ${env.JOB_NAME}':</p>
<p>Check console output at "<a href='${env.BUILD_URL}/console'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>"""
// Override default values based on build status
if (buildStatus == 'STARTED') {
color = 'YELLOW'
colorCode = '#FFFF00'
}
else if (buildStatus == 'SUCCESS') {
color = 'GREEN'
colorCode = '#00FF00'
}
else {
color = 'RED'
colorCode = '#FF0000'
}
// Send notifications
slackSend (color: colorCode, message: summary)
/*
emailext (
subject: subject,
body: details,
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
*/
}