Skip to content

Commit 8bbb124

Browse files
authored
Merge pull request #594 from thaJeztah/split_stages
Jenkinsfile: run builds in parallel, and build all distro/arches
2 parents 94f2818 + 5413760 commit 8bbb124

File tree

2 files changed

+135
-60
lines changed

2 files changed

+135
-60
lines changed

Jenkinsfile

Lines changed: 125 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,130 @@
22

33
def branch = env.CHANGE_TARGET ?: env.BRANCH_NAME
44

5-
test_steps = [
6-
'deb': { ->
7-
stage('Ubuntu and Debian Package') {
8-
wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) {
9-
try {
10-
checkout scm
11-
sh "make REF=$branch checkout"
12-
sh "make -C deb ubuntu-focal ubuntu-hirsute ubuntu-impish debian-bullseye"
13-
} finally {
14-
sh "make clean"
15-
}
16-
}
17-
}
18-
},
19-
'raspbian': { ->
20-
stage('Raspbian') {
21-
wrappedNode(label: 'ubuntu && armhf', cleanWorkspace: true) {
22-
try {
23-
checkout scm
24-
sh "make REF=$branch checkout"
25-
sh "make -C deb raspbian-buster raspbian-bullseye"
26-
} finally {
27-
sh "make clean"
28-
}
29-
}
30-
}
31-
},
32-
'rpm': { ->
33-
stage('Centos 7 and 8 RPM Packages') {
34-
wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) {
35-
try {
36-
checkout scm
37-
sh "make REF=$branch checkout"
38-
sh "make -C rpm centos-7 centos-8 fedora-35"
39-
} finally {
40-
sh "make clean"
41-
}
42-
}
43-
}
44-
},
45-
'static-cross': { ->
46-
stage('Static Linux Binaries') {
47-
wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) {
48-
try {
49-
checkout scm
50-
sh "make REF=$branch checkout"
51-
sh "make REF=$branch DOCKER_BUILD_PKGS='static-linux cross-mac cross-win' static"
52-
} finally {
53-
sh "make clean"
54-
}
55-
}
56-
}
57-
},
5+
def pkgs = [
6+
[target: "centos-7", image: "centos:7", arches: ["amd64", "aarch64"]], // (EOL: June 30, 2024)
7+
[target: "centos-8", image: "centos:8", arches: ["amd64", "aarch64"]],
8+
[target: "debian-buster", image: "debian:buster", arches: ["amd64", "aarch64", "armhf"]], // Debian 10 (EOL: 2024)
9+
[target: "debian-bullseye", image: "debian:bullseye", arches: ["amd64", "aarch64", "armhf"]], // Debian 11 (Next stable)
10+
[target: "fedora-33", image: "fedora:33", arches: ["amd64", "aarch64"]], // EOL: November 23, 2021
11+
[target: "fedora-34", image: "fedora:34", arches: ["amd64", "aarch64"]], // EOL: May 17, 2022
12+
[target: "fedora-35", image: "fedora:35", arches: ["amd64", "aarch64"]], // EOL: November 30, 2022
13+
[target: "raspbian-buster", image: "balenalib/rpi-raspbian:buster", arches: ["armhf"]], // Debian/Raspbian 10 (EOL: 2024)
14+
[target: "raspbian-bullseye", image: "balenalib/rpi-raspbian:bullseye", arches: ["armhf"]], // Debian/Raspbian 11 (Next stable)
15+
[target: "ubuntu-bionic", image: "ubuntu:bionic", arches: ["amd64", "aarch64", "armhf"]], // Ubuntu 18.04 LTS (End of support: April, 2023. EOL: April, 2028)
16+
[target: "ubuntu-focal", image: "ubuntu:focal", arches: ["amd64", "aarch64", "armhf"]], // Ubuntu 20.04 LTS (End of support: April, 2025. EOL: April, 2030)
17+
[target: "ubuntu-hirsute", image: "ubuntu:hirsute", arches: ["amd64", "aarch64", "armhf"]], // Ubuntu 21.04 (EOL: January, 2022)
18+
[target: "ubuntu-impish", image: "ubuntu:impish", arches: ["amd64", "aarch64", "armhf"]], // Ubuntu 21.10 (EOL: July, 2022)
5819
]
5920

60-
parallel(test_steps)
21+
def genBuildStep(LinkedHashMap pkg, String arch) {
22+
def nodeLabel = "linux&&${arch}"
23+
def platform = ""
24+
def branch = env.CHANGE_TARGET ?: env.BRANCH_NAME
25+
26+
if (arch == 'armhf') {
27+
// Running armhf builds on EC2 requires --platform parameter
28+
// Otherwise it accidentally pulls armel images which then breaks the verify step
29+
platform = "--platform=linux/${arch}"
30+
nodeLabel = "${nodeLabel}&&ubuntu"
31+
} else {
32+
nodeLabel = "${nodeLabel}&&ubuntu-2004"
33+
}
34+
return { ->
35+
wrappedNode(label: nodeLabel, cleanWorkspace: true) {
36+
stage("${pkg.target}-${arch}") {
37+
// This is just a "dummy" stage to make the distro/arch visible
38+
// in Jenkins' BlueOcean view, which truncates names....
39+
sh 'echo starting...'
40+
}
41+
stage("info") {
42+
sh 'docker version'
43+
sh 'docker info'
44+
}
45+
stage("build") {
46+
try {
47+
checkout scm
48+
sh "make REF=$branch ${pkg.target}"
49+
} finally {
50+
sh "make clean"
51+
}
52+
}
53+
}
54+
}
55+
}
56+
57+
def build_package_steps = [
58+
'static-linux': { ->
59+
wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) {
60+
stage("static-linux") {
61+
// This is just a "dummy" stage to make the distro/arch visible
62+
// in Jenkins' BlueOcean view, which truncates names....
63+
sh 'echo starting...'
64+
}
65+
stage("info") {
66+
sh 'docker version'
67+
sh 'docker info'
68+
}
69+
stage("build") {
70+
try {
71+
checkout scm
72+
sh "make REF=$branch DOCKER_BUILD_PKGS='static-linux' static"
73+
} finally {
74+
sh "make clean"
75+
}
76+
}
77+
}
78+
},
79+
'cross-mac': { ->
80+
wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) {
81+
stage("cross-mac") {
82+
// This is just a "dummy" stage to make the distro/arch visible
83+
// in Jenkins' BlueOcean view, which truncates names....
84+
sh 'echo starting...'
85+
}
86+
stage("info") {
87+
sh 'docker version'
88+
sh 'docker info'
89+
}
90+
stage("build") {
91+
try {
92+
checkout scm
93+
sh "make REF=$branch DOCKER_BUILD_PKGS='cross-mac' static"
94+
} finally {
95+
sh "make clean"
96+
}
97+
}
98+
}
99+
},
100+
'cross-win': { ->
101+
wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) {
102+
stage("cross-win") {
103+
// This is just a "dummy" stage to make the distro/arch visible
104+
// in Jenkins' BlueOcean view, which truncates names....
105+
sh 'echo starting...'
106+
}
107+
stage("info") {
108+
sh 'docker version'
109+
sh 'docker info'
110+
}
111+
stage("build") {
112+
try {
113+
checkout scm
114+
sh "make REF=$branch DOCKER_BUILD_PKGS='cross-win' static"
115+
} finally {
116+
sh "make clean"
117+
}
118+
}
119+
}
120+
},
121+
]
122+
123+
def genPackageSteps(opts) {
124+
return opts.arches.collectEntries {
125+
["${opts.image}-${it}": genBuildStep(opts, it)]
126+
}
127+
}
128+
129+
build_package_steps << pkgs.collectEntries { genPackageSteps(it) }
130+
131+
parallel(build_package_steps)

Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,17 @@ clean: clean-src ## remove build artifacts
6363
$(MAKE) -C deb clean
6464
$(MAKE) -C static clean
6565

66-
.PHONY: rpm
67-
rpm: checkout ## build rpm packages
68-
$(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) rpm
66+
.PHONY: deb rpm
67+
deb rpm: checkout ## build rpm/deb packages
68+
$(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $@
6969

70-
.PHONY: deb
71-
deb: checkout ## build deb packages
72-
$(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) deb
70+
.PHONY: centos-% fedora-% rhel-%
71+
centos-% fedora-% rhel-%: checkout ## build rpm packages for the specified distro
72+
$(MAKE) -C rpm VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $@
73+
74+
.PHONY: debian-% raspbian-% ubuntu-%
75+
debian-% raspbian-% ubuntu-%: checkout ## build deb packages for the specified distro
76+
$(MAKE) -C deb VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $@
7377

7478
.PHONY: static
7579
static: DOCKER_BUILD_PKGS:=static-linux cross-mac cross-win cross-arm

0 commit comments

Comments
 (0)