forked from AliceO2Group/alice-fit-fpga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
80 lines (78 loc) · 2.08 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
pipeline {
agent any
options {
timeout(time: 2, unit: 'HOURS')
parallelsAlwaysFailFast()
}
environment {
HOST_JENKINS_HOME = "/var/jenkins_home"
NFS_ROOT = '/mnt/fit-hardware-blobs'
BITSTREAMS_DIR = "${NFS_ROOT}/bitstreams"
BUILD_DIR = "${BRANCH_NAME}-${GIT_COMMIT}"
TARGET_DIR = "${BITSTREAMS_DIR}/${BUILD_DIR}"
}
stages {
stage('Get job directory for purging') {
steps {
sh('pwd')
}
}
stage('Purge previous builds') {
steps {
script {
def hi = Hudson.instance
def pname = env.JOB_NAME.split('/')[0]
hi.getItem(pname).getItem(env.JOB_BASE_NAME).getBuilds().each{ build ->
def exec = build.getExecutor()
if (build.number < currentBuild.number && exec != null) {
exec.interrupt(
Result.ABORTED,
new CauseOfInterruption.UserInterruption(
"Aborted by #${currentBuild.number}"
)
)
println("Aborted previous running build #${build.number}")
} else {
println("Build is not running or is current build, not aborting - #${build.number}")
}
}
}
}
}
stage('Build FIT bitstreams') {
parallel {
stage('PM') {
steps {
sh('./software/ci/build.sh PM')
}
}
stage('TCM') {
steps {
sh('./software/ci/build.sh TCM')
}
}
stage('FTM') {
steps {
sh('./software/ci/build.sh FTM')
}
}
}
}
stage('Copy bitstreams') {
steps {
sh("mkdir -p ${TARGET_DIR}")
sh("cp firmware/FT0/*/build/*.bit ${TARGET_DIR}")
sh("cp firmware/FT0/*/build/*.bin ${TARGET_DIR}")
sh("cp firmware/FT0/*/build/*_logs.tar.gz ${TARGET_DIR}")
}
}
stage('Update latest') {
when {
branch 'master'
}
steps {
sh('cd ${BITSTREAMS_DIR} && ln -sfn ${BUILD_DIR} latest && cd -')
}
}
}
}