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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
// Copyright (C) 2019-2020 VyOS maintainers and contributors
//
// This program is free software; you can redistribute it and/or modify
// in order to easy exprort images built to "external" world
// it under the terms of the GNU General Public License version 2 or later as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@NonCPS
// Using a version specifier library, use 'current' branch. The underscore (_)
// is not a typo! You need this underscore if the line immediately after the
// @Library annotation is not an import statement!
@Library('vyos-build@current')_
/* Only keep the most recent builds. */
def projectProperties = [
[$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '1']],
]
properties(projectProperties)
setDescription()
node('Docker') {
stage('Define Agent') {
script {
// create container name on demand
def branchName = getGitBranchName()
// Adjust PR target branch name so we can re-map it to the proper
// Docker image. CHANGE_ID is set only for pull requests, so it is
// safe to access the pullRequest global variable
if (env.CHANGE_ID) {
branchName = "${env.CHANGE_TARGET}".toLowerCase()
}
if (branchName.equals("master")) {
branchName = "current"
}
env.DOCKER_IMAGE = "vyos/vyos-build:" + branchName
}
}
}
pipeline {
agent {
docker {
args "--sysctl net.ipv6.conf.lo.disable_ipv6=0 -e GOSU_UID=1006 -e GOSU_GID=1006"
image "${env.DOCKER_IMAGE}"
alwaysPull true
}
}
options {
disableConcurrentBuilds()
timeout(time: 120, unit: 'MINUTES')
timestamps()
}
environment {
DEBIAN_ARCH = sh(returnStdout: true, script: 'dpkg --print-architecture').trim()
BASE_DIR = getJenkinsfilePath()
CHANGESET_DIR = getChangeSetPath()
}
stages {
stage('Fetch') {
steps {
script {
checkout scm
echo env.CHANGESET_DIR
}
}
}
stage('Git Clone - Components') {
parallel {
stage('Kernel') {
when {
beforeOptions true
beforeAgent true
anyOf {
changeset pattern: "${env.CHANGESET_DIR}"
triggeredBy 'TimerTrigger'
triggeredBy cause: "UserIdCause"
}
}
steps {
script {
dir(env.BASE_DIR) {
sh '''
KERNEL_VER='5.10.6'
gpg2 --locate-keys torvalds@kernel.org gregkh@kernel.org
curl -OL https://www.kernel.org/pub/linux/kernel/v5.x/linux-${KERNEL_VER}.tar.xz
curl -OL https://www.kernel.org/pub/linux/kernel/v5.x/linux-${KERNEL_VER}.tar.sign
xz -cd linux-${KERNEL_VER}.tar.xz | gpg2 --verify linux-${KERNEL_VER}.tar.sign -
if [ $? -ne 0 ]; then
exit 1
fi
tar xf linux-${KERNEL_VER}.tar.xz
ln -s linux-${KERNEL_VER} linux
'''
}
}
}
}
stage('Kernel Firmware') {
when {
beforeOptions true
beforeAgent true
anyOf {
changeset pattern: "${env.CHANGESET_DIR}"
triggeredBy 'TimerTrigger'
triggeredBy cause: "UserIdCause"
}
}
steps {
dir(env.BASE_DIR + '/linux-firmware') {
checkout([$class: 'GitSCM',
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanCheckout'],
[$class: 'CloneOption', depth: 1, noTags: false, reference: '', shallow: true]],
branches: [[name: '20201022' ]],
userRemoteConfigs: [[credentialsId: 'GitHub-vyosbot', url: 'https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git']]])
}
}
}
stage('Accel-PPP') {
when {
beforeOptions true
beforeAgent true
anyOf {
changeset pattern: "${env.CHANGESET_DIR}"
triggeredBy 'TimerTrigger'
triggeredBy cause: "UserIdCause"
}
}
steps {
dir(env.BASE_DIR + '/accel-ppp') {
checkout([$class: 'GitSCM',
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanCheckout']],
branches: [[name: '59f8e1bc3f199c8d0d985253e19a74ad87130179' ]],
userRemoteConfigs: [[credentialsId: 'GitHub-vyosbot', url: 'https://github.com/accel-ppp/accel-ppp.git']]])
}
}
}
}
}
stage('Compile Kernel') {
when {
beforeOptions true
beforeAgent true
anyOf {
changeset pattern: "${env.CHANGESET_DIR}"
triggeredBy 'TimerTrigger'
triggeredBy cause: "UserIdCause"
}
}
steps {
dir(env.BASE_DIR) {
sh "./build-kernel.sh"
}
}
}
stage('Kernel Module(s)') {
parallel {
stage('Accel-PPP') {
when {
beforeOptions true
beforeAgent true
anyOf {
changeset pattern: "${env.CHANGESET_DIR}"
triggeredBy 'TimerTrigger'
triggeredBy cause: "UserIdCause"
}
}
steps {
dir(env.BASE_DIR) {
sh "./build-accel-ppp.sh"
}
}
}
stage('Intel Driver(s)') {
when {
beforeOptions true
beforeAgent true
anyOf {
changeset pattern: "${env.CHANGESET_DIR}"
triggeredBy 'TimerTrigger'
triggeredBy cause: "UserIdCause"
}
}
steps {
dir(env.BASE_DIR) {
sh "./build-intel-drivers.sh"
}
}
}
stage('Intel QuickAssist Technology') {
when {
beforeOptions true
beforeAgent true
anyOf {
changeset pattern: "${env.CHANGESET_DIR}"
triggeredBy 'TimerTrigger'
triggeredBy cause: "UserIdCause"
}
}
steps {
dir(env.BASE_DIR) {
sh "./build-intel-qat.sh"
}
}
}
}
}
// This stage should not be run in the parallel section as it will call "make"
// again on the kernel source and this could confuse other build systems
// like generating Intel or Accel-PPP drivers. Better safe then sorry!
stage('Linux Firmware') {
when {
beforeOptions true
beforeAgent true
anyOf {
changeset pattern: "${env.CHANGESET_DIR}"
triggeredBy 'TimerTrigger'
triggeredBy cause: "UserIdCause"
}
}
steps {
dir(env.BASE_DIR) {
sh "./build-linux-firmware.sh"
}
}
}
}
post {
cleanup {
deleteDir()
}
success {
script {
dir(env.BASE_DIR) {
// archive *.deb artifact on custom builds, deploy to repo otherwise
if ( isCustomBuild()) {
archiveArtifacts artifacts: '*.deb', fingerprint: true
} else {
// publish build result, using SSH-dev.packages.vyos.net Jenkins Credentials
sshagent(['SSH-dev.packages.vyos.net']) {
// build up some fancy groovy variables so we do not need to write/copy
// every option over and over again!
def RELEASE = getGitBranchName()
if (getGitBranchName() == "master") {
RELEASE = 'current'
}
def VYOS_REPO_PATH = '/home/sentrium/web/dev.packages.vyos.net/public_html/repositories/' + RELEASE + '/'
if (getGitBranchName() == "crux")
VYOS_REPO_PATH += 'vyos/'
def SSH_OPTS = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR'
def SSH_REMOTE = 'khagen@10.217.48.113'
echo "Uploading package(s) and updating package(s) in the repository ..."
files = findFiles(glob: '*.deb')
files.each { PACKAGE ->
def ARCH = sh(returnStdout: true, script: "dpkg-deb -f ${PACKAGE} Architecture").trim()
def SUBSTRING = sh(returnStdout: true, script: "dpkg-deb -f ${PACKAGE} Package").trim()
def SSH_DIR = '~/VyOS/' + RELEASE + '/' + ARCH
def ARCH_OPT = ''
if (ARCH != 'all')
ARCH_OPT = '-A ' + ARCH
// No need to explicitly check the return code. The pipeline
// will fail if sh returns a non 0 exit code
sh """
ssh ${SSH_OPTS} ${SSH_REMOTE} -t "bash --login -c 'mkdir -p ${SSH_DIR}'"
scp ${SSH_OPTS} ${PACKAGE} ${SSH_REMOTE}:${SSH_DIR}/
ssh ${SSH_OPTS} ${SSH_REMOTE} -t "uncron-add 'reprepro -v -b ${VYOS_REPO_PATH} ${ARCH_OPT} remove ${RELEASE} ${SUBSTRING}'"
ssh ${SSH_OPTS} ${SSH_REMOTE} -t "uncron-add 'reprepro -v -b ${VYOS_REPO_PATH} deleteunreferenced'"
ssh ${SSH_OPTS} ${SSH_REMOTE} -t "uncron-add 'reprepro -v -b ${VYOS_REPO_PATH} ${ARCH_OPT} includedeb ${RELEASE} ${SSH_DIR}/${PACKAGE}'"
"""
}
}
}
}
}
}
}
}
|