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
|
#!/usr/bin/env groovy
/*
Copyright (C) 2018 Collabora Limited
Author: Guillaume Tucker <guillaume.tucker@collabora.com>
This module is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library 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 Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* ----------------------------------------------------------------------------
* Jenkins parameters
ARCH
CPU architecture as understood by the Linux kernel build system
DEFCONFIG
Linux kernel defconfig to build
SRC_TARBALL
URL of the kernel source tarball
BUILD_CONFIG
Name of the build configuration
GIT_DESCRIBE
Output of 'git describe' at the revision of the snapshot
GIT_DESCRIBE_VERBOSE
Verbose output of 'git describe' at the revision of the snapshot
COMMIT_ID
Git commit SHA1 at the revision of the snapshot
BUILD_ENVIRONMENT
Name of the build environment
NODE_LABEL
Label to use to choose a node on which to run this job
PUBLISH (boolean)
Publish build results via the KernelCI backend API
EMAIL (boolean)
Send build results via email
KCI_API_URL (https://api.kernelci.org)
URL of the KernelCI backend API
KCI_TOKEN_ID
Identifier of the KernelCI backend API token stored in Jenkins
KCI_CORE_URL (https://github.com/kernelci/kernelci-core.git)
URL of the kernelci-core repository
KCI_CORE_BRANCH (master)
Name of the branch to use in the kernelci-core repository
DOCKER_BASE
Dockerhub base address used for the build images
PARALLEL_BUILDS
Number of kernel builds to run in parallel
*/
@Library('kernelci') _
import org.kernelci.util.Job
def buildConfig(kdir, kci_core) {
def jopt = ""
if (params.PARALLEL_BUILDS)
jopt = "-j${params.PARALLEL_BUILDS}"
dir(kci_core) {
sh(script: """\
./kci_build \
build_kernel \
--kdir=${kdir} \
--defconfig=${params.DEFCONFIG} \
--arch=${params.ARCH} \
--build-env=${params.BUILD_ENVIRONMENT} \
--verbose \
${jopt} \
|| echo 'Kernel build failed'
""")
sh(script: """\
./kci_build \
install_kernel \
--kdir=${kdir} \
--config=${params.BUILD_CONFIG} \
--describe=${params.GIT_DESCRIBE} \
--describe-verbose=${params.GIT_DESCRIBE_VERBOSE} \
--commit=${params.COMMIT_ID} \
""")
withCredentials([string(credentialsId: params.KCI_TOKEN_ID,
variable: 'SECRET')]) {
sh(script: """\
./kci_build \
push_kernel \
--kdir=${kdir} \
--token=${SECRET} \
--api=${params.KCI_API_URL} \
""")
sh(script: """\
./kci_build \
publish_kernel \
--kdir=${kdir} \
--token=${SECRET} \
--api=${params.KCI_API_URL} \
""")
}
}
dir("linux/_install_") {
archiveArtifacts("*.json")
}
}
node("docker" && params.NODE_LABEL) {
def j = new Job()
def kci_core = "${env.WORKSPACE}/kernelci-core"
def kdir = "${env.WORKSPACE}/linux"
def docker_image = null
print("""\
Config: ${params.BUILD_CONFIG}
CPU arch: ${params.ARCH}
Describe: ${params.GIT_DESCRIBE}
Revision: ${params.COMMIT_ID}
Defconfig: ${params.DEFCONFIG}
Compiler: ${params.BUILD_ENVIRONMENT}""")
j.dockerPullWithRetry("${params.DOCKER_BASE}base").inside() {
j.cloneKciCore(kci_core, params.KCI_CORE_URL, params.KCI_CORE_BRANCH)
build_env_docker_image = j.dockerImageName(
kci_core, params.BUILD_ENVIRONMENT, params.ARCH)
docker_image = "${params.DOCKER_BASE}${build_env_docker_image}"
}
j.dockerPullWithRetry(docker_image).inside() {
stage("Init") {
timeout(time: 30, unit: 'MINUTES') {
dir(kci_core) {
sh(script: """./kci_build pull_tarball \
--kdir ${kdir} \
--url ${params.SRC_TARBALL} \
--retries=12 \
""")
}
}
}
stage("Build") {
timeout(time: 180, unit: 'MINUTES') {
buildConfig(kdir, kci_core)
sh(script: "rm -rf ${kdir}")
}
}
}
}
|