discover: Add --debug to kexec
[petitboot] / jenkins / pb-build-matrix.groovy
1 #!groovy
2 // Builds pb-builder image and runs build-pb script.
3 //
4 // The `jenkins` user must be in the `docker` user group.
5 // Requires nodes with labels: `amd64`, `arm64`, `docker`.
6 // Required plugins: build-timeout, copyartifact, git, pipeline, ssh-agent,
7 // workflow-aggregator.
8
9 properties([
10     buildDiscarder(logRotator(daysToKeepStr: '30', numToKeepStr: '5')),
11     parameters([
12     string(name: 'BUILD_ARCH_LIST',
13         defaultValue: 'amd64 arm64',
14         description: 'List of Jenkins node architectures to build on.'),
15     booleanParam(name: 'DOCKER_PURGE',
16         defaultValue: false,
17         description: 'Remove existing pb-builder docker image and rebuild.'),
18     booleanParam(name: 'DRY_RUN',
19         defaultValue: false,
20         description: 'Dry run, do not build.'),
21     string(name: 'GIT_URL',
22         defaultValue: 'git://ozlabs.org/petitboot',
23         description: 'URL of petitboot git repository.'),
24     ])
25 ])
26
27 def build_pb = { String _build_arch, Boolean _dry_run, String _git_url,
28     Boolean _purge
29     ->
30     String build_arch = _build_arch
31     Boolean dry_run = _dry_run
32     String git_url = _git_url
33     Boolean purge = _purge
34     String builder_args = ""
35     String pb_args = ""
36
37     if (dry_run) {
38         builder_args += " --dry-run"
39         pb_args += " --dry-run"
40     }
41     if (purge) {
42         builder_args += " --purge"
43     }
44
45     // timeout if no build_arch node is available.
46     timeout(time: 15, unit: 'MINUTES') {
47         node("${build_arch} && docker") {
48             git(poll: false, changelog: false, url: git_url)
49
50             stage("[${build_arch}--build-builder]") {
51                 sh("""./docker/build-builder --verbose ${builder_args}""")
52             }
53             stage("[${build_arch}--build-pb]") {
54                 sh("""./docker/build-pb --verbose --check ${pb_args}""")
55             }
56             stage('Post-build') {
57                 String result_file = "${BUILD_TAG}-${build_arch}-test-results.tar.xz"
58                 String test_info = """build_arch=${build_arch}
59     BUILD_URL=${BUILD_URL}
60     BUILD_TAG=${BUILD_TAG}
61     GIT_URL=${GIT_URL}
62     """
63
64                 writeFile(file: 'test-info.txt', text: test_info)
65                 sh("tar -cJf ${result_file} test-info.txt test-suite.log \
66                     \$(find test -name '*.log')")
67                 archiveArtifacts  "${result_file}"
68             }
69         }
70     }
71 }
72
73 def build_map = [:]
74 build_map.failFast = false
75
76 for (build_arch in params.BUILD_ARCH_LIST.split()) {
77     build_map[build_arch] = build_pb.curry(build_arch, params.DRY_RUN,
78         params.GIT_URL, params.DOCKER_PURGE)
79 }
80
81 parallel build_map