-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
62 lines (58 loc) · 2.06 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
timestamps {
node("ubuntu18-agent") {
catchError {
checkout scm
dir_exists = sh (
script: "test -d 'tests' && echo 'Y' || echo 'N' ",
returnStdout: true
).trim()
if (dir_exists == 'N'){
currentBuild.result= 'FAILURE'
echo "No tests directory found! Exiting."
return
}
try {
stage("Prerequisites"){
// Change to corresponding CORE_BRANCH as required
// e.g. FOGL-xxxx, main etc.
sh '''
CORE_BRANCH='develop'
${HOME}/buildFledge ${CORE_BRANCH} ${WORKSPACE}
'''
}
} catch (e) {
currentBuild.result = 'FAILURE'
echo "Failed to build Fledge; required to run the tests!"
return
}
try {
stage("Run Tests"){
echo "Executing tests..."
sh '''
. ${WORKSPACE}/PLUGIN_PR_ENV/bin/activate
export FLEDGE_ROOT=$HOME/fledge && export PYTHONPATH=$HOME/fledge/python
cd tests && python3 -m pytest -vv --ignore=system --ignore=api --junit-xml=test_result.xml
'''
echo "Done."
}
} catch (e) {
result = "TESTS FAILED"
currentBuild.result = 'FAILURE'
echo "Tests failed!"
}
try {
stage("Publish Test Report"){
junit "tests/test_result.xml"
}
} catch (e) {
result = "TEST REPORT GENERATION FAILED"
currentBuild.result = 'FAILURE'
echo "Failed to generate test reports!"
}
}
stage ("Cleanup"){
// Add here if any cleanup is required
echo "Done."
}
}
}