-
Notifications
You must be signed in to change notification settings - Fork 9
/
Jenkinsfile
113 lines (104 loc) · 3.32 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
#! /usr/bin/env groovy
/*
* This Jenkinsfile is intended to run on our internal server and may fail
* anywhere else.
* It makes assumptions about plugins being installed, labels mapping to nodes
* that can build what is needed, etc.
*/
String proj = "perfect-cell"
String build = "Debug" // Debug | Release, debug build enables testing.
String arch = "ARM_GCC_541"
pipeline {
agent none
options {
timeout(time: 30, unit: 'MINUTES')
}
environment {
PSOC_VER = "4.1"
}
stages {
stage('Build') {
agent { label 'klab' }
steps {
// Build the $BUILD version of the project.
// Save to perfect-cell.cydsn\CortexM3\$ARCH\$BUILD\
bat "${env.CYPRJMGR} -wrk \"${proj}.cydsn\\${proj}.cywrk\" -c ${build} -rebuild"
}
}
stage('Program') {
agent { label 'klab' }
steps {
bat "python build_tools\\psoc_program.py \"${proj}.cydsn\\CortexM3\\${arch}\\${build}\\${proj}.hex\""
}
}
stage('Test') {
// TODO: These steps could probably be run on the EC2 instance
agent { label 'klab' }
steps {
bat "python build_tools\\pre_build.py"
bat "python tests\\power_test.py ${getCommitSHA()}"
timeout(10) { // Only attempt for 10 minutes
waitUntil {
script {
def r = bat script: "python tests\\ci_test.py ${getCommitSHA()} \"${env.BUILD_TIMESTAMP}\"", returnStatus: true
if (r != 0) { sleep 30 }
return (r == 0)
}
}
}
// power off the psoc device after running the tests
//bat "python build_tools\\psoc_program.py --power-off-device"
}
}
}
post {
success {
node('master') {
checkout scm
sh "python3 ./build_tools/post_build.py \"SUCCESS\""
}
}
unstable {
node('master') {
checkout scm
sh "python3 ./build_tools/post_build.py \"UNSTABLE\""
}
}
failure {
node('master') {
checkout scm
sh "python3 ./build_tools/post_build.py \"FAILURE\""
}
}
notBuilt {
node('master') {
checkout scm
sh "python3 ./build_tools/post_build.py \"NOT_BUILT\""
}
}
aborted {
node('master') {
checkout scm
sh "python3 ./build_tools/post_build.py \"ABORTED\""
}
}
always {
node('klab') {
deleteDir() // clean up our workspace on the slave
}
node('master') {
checkout scm
sh "python3 tests/read_build_log.py \"${env.BUILD_TIMESTAMP}\""
//sh "echo ${getBuildResult()}"
deleteDir() // clean up our workspace on master
}
}
}
}
String getBuildResult() {
return "${buildStatus}"
}
String getCommitSHA() {
bat "${env.GIT} rev-parse HEAD > .git/current-commit"
return readFile(".git/current-commit").trim()
}