-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
107 lines (87 loc) · 2.45 KB
/
Jenkinsfile
File metadata and controls
107 lines (87 loc) · 2.45 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
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
node {
def icon = ""
def files
def result
try {
// checkout repo locally
stage('checkout changes from PR') {
checkout([
$class: 'GitSCM',
branches: [[name: '${ghprbActualCommit}']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [
[
name: 'origin',
refspec: '+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*',
url: 'https://github.com/afuscella/ABAP-Z-LAC.git']
]
])
}
dir('src') {
files = findFiles excludes: '', glob: '*.clas.abap'
for (file in files) {
echo file.name
}
}
// delete current dir before running tests
deleteDir()
// get pipeline rules
sh "git clone https://github.com/afuscella/jenkins-pipeline-pvt.git ."
// switch to 'abap' folder
dir('abap') {
sh "newman run collections/get-authentication-token.collection.json " +
"-e NPL.environment.json " +
"-r cli,junit " +
"--insecure " +
"--export-environment NPL.environment.json " +
"--export-globals globals.json"
stage('unit test with coverage') {
sh "newman run collections/run-unit-test-with-coverage.collection.json " +
"-e NPL.environment.json " +
"-r cli,junit " +
"--insecure " +
"--globals globals.json " +
"--reporter-junit-export " +
"--export-globals globals.json" }
stage('collect unit test results') {
sh "newman run collections/get-unit-test-with-coverage-result.collection.json " +
"-e NPL.environment.json " +
"-r cli,junit " +
"--insecure " +
"--reporter-junit-export " +
"--globals globals.json" }
}
result = 'SUCCESS'
icon = "completed.gif"
// error handling
} catch (err) {
notify("Failed ${err}")
result = 'FAILURE'
icon = "delete.gif"
}
collectTestResults()
addBadge(icon: icon)
currentBuild.result = result
}
def collectTestResults() {
try {
dir('abap') {
step([
$class: 'JUnitResultArchiver',
testResults: 'newman/*.xml'
])
}
} catch (err) {
echo ${err}
}
}
def notify(status){
emailext (
to: "your@email.com",
subject: "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at <a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
)
}