forked from ARM-software/synchronization-benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
71 lines (63 loc) · 2.34 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
import static groovy.io.FileType.FILES
import static groovy.io.FileType.DIRECTORIES
def getRepoURL() {
sh "git config --get remote.origin.url > .git/remote-url"
return readFile(".git/remote-url").trim()
}
void setBuildStatus(String message, String state, String context) {
repoUrl = getRepoURL();
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: repoUrl],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: context],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ],
statusBackrefSource: [ $class: "ManuallyEnteredBackrefSource", backref: ""]
]);
}
node {
stage('checkout') {
checkout scm
}
stage('Build') {
setBuildStatus("Building code", 'PENDING', 'Build');
def fails = []
def dir = new File("${env.WORKSPACE}/benchmarks/");
dir.traverse(type: DIRECTORIES, maxDepth: 0) {
//build
try {
sh "make -C ${it}"
}
catch (exc) {
fails.add(it.toString().substring(env.WORKSPACE.length()))
}
}
if (fails) {
setBuildStatus("${fails} failed to build", 'FAILURE', 'Build');
error "${fails} failed to build"
}
setBuildStatus("Build Successful!", 'SUCCESS', 'Build');
}
stage('Test') {
setBuildStatus("Testing code", 'PENDING', 'Test');
fails = []
dir = new File("${env.WORKSPACE}/benchmarks/");
// Run all scripts starting with the prefix "test"
dir.traverse(type: DIRECTORIES, maxDepth: 0) {
def scr = new File("${it}/scripts/")
scr.traverse(type: FILES, filter: ~/.*\/test[^\/]*/) {
try {
sh "${it}"
}
catch (exc) {
fails.add(it.toString().substring(env.WORKSPACE.length()))
}
}
}
if (fails) {
setBuildStatus("Tests scripts: ${fails} Failed", 'FAILURE', 'Test');
error "Tests scripts: ${fails} Failed"
}
setBuildStatus("Tests Passed!", 'SUCCESS', 'Test');
}
}