2 // Builds pb-builder image and runs build-pb script.
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.
10 buildDiscarder(logRotator(daysToKeepStr: '30', numToKeepStr: '5')),
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',
17 description: 'Remove existing pb-builder docker image and rebuild.'),
18 booleanParam(name: 'DRY_RUN',
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.'),
27 def build_pb = { String _build_arch, Boolean _dry_run, String _git_url,
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 = ""
38 builder_args += " --dry-run"
39 pb_args += " --dry-run"
42 builder_args += " --purge"
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)
50 stage("[${build_arch}--build-builder]") {
51 sh("""./docker/build-builder --verbose ${builder_args}""")
53 stage("[${build_arch}--build-pb]") {
54 sh("""./docker/build-pb --verbose --check ${pb_args}""")
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}
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}"
74 build_map.failFast = false
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)