-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
118 lines (98 loc) · 4.21 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
114
115
116
117
118
def build_badge = addEmbeddableBadgeConfiguration(id: 'build', subject: 'Build')
def pack_badge = addEmbeddableBadgeConfiguration(id: 'build', subject: 'Build')
def runBuild() {
sh 'mkdir .src && mv * .src && mv .src src && cd src'
sh '. /opt/ros/kinetic/setup.sh && catkin_init_workspace src && catkin_make -j4'
}
def runPack() {
sh ''' \
VERSION=$(cat src/thomas_drivers/package.xml | \
grep "<version>" | cut -d">" -f2 | cut -d"<" -f1) && \
. /opt/ros/kinetic/setup.sh && \
PKG_NAME="thomas-drivers" && \
WORKSPACE="thomas_drivers" && \
PKG_DIR="./${PKG_NAME}-${VERSION}" && \
WORKSPACE_DIR="${PKG_DIR}/opt/thomas/${WORKSPACE}" && \
mkdir -p ${WORKSPACE_DIR} && \
catkin_make install -DCMAKE_INSTALL_PREFIX="${WORKSPACE_DIR}" && \
mkdir ${PKG_DIR}/DEBIAN && \
CONTROL_FILE=${PKG_DIR}/DEBIAN/control && \
echo "Package: ${PKG_NAME}" >> ${CONTROL_FILE} && \
echo "Version: ${VERSION}" >> ${CONTROL_FILE} && \
echo "Section: base" >> ${CONTROL_FILE} && \
echo "Priority: optional" >> ${CONTROL_FILE} && \
echo "Architecture: amd64" >> ${CONTROL_FILE} && \
echo "Depends: ros-kinetic-desktop-full" >> ${CONTROL_FILE} && \
echo "Maintainer: Li Tang <[email protected]>" >> ${CONTROL_FILE} && \
echo "Description: Some common drivers" >> ${CONTROL_FILE} && \
echo " Now includes velodyne, xsens and flir cameras" >> ${CONTROL_FILE} && \
chmod -R a-s ${PKG_DIR} && \
dpkg-deb --build ${PKG_DIR} \
'''
}
pipeline {
agent {
label "master"
}
stages {
stage('Build') {
agent {
docker {
image 'thomas:ros-kinetic-thomas-base'
reuseNode true
}
}
steps {
script {
build_badge.setStatus('building')
try {
runBuild()
build_badge.setStatus('passing')
} catch (Exception err) {
build_badge.setStatus('failing')
error 'Build failed'
}
}
}
}
stage('Pack') {
when {
branch 'master'
}
agent {
docker {
image 'thomas:ros-kinetic-thomas-base'
reuseNode true
}
}
steps {
script {
pack_badge.setStatus('building')
try {
runPack()
pack_badge.setStatus('passing')
} catch (Exception err) {
pack_badge.setStatus('failing')
error 'Pack failed'
}
}
}
}
stage('Publish') {
when {
branch 'master'
}
steps {
sh 'cp thomas-drivers-*.deb /pkgs'
}
}
stage('Dockerize') {
when {
branch 'master'
}
steps {
build job: 'thomas_docker/master', propagate: true, wait: true, parameters: [string(name: 'TRIGGER_SOURCE', value: "thomas_drivers")]
}
}
}
}