-
Notifications
You must be signed in to change notification settings - Fork 141
/
Jenkinsfile
151 lines (142 loc) · 7.36 KB
/
Jenkinsfile
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
#!groovy
def branch = env.CHANGE_TARGET ?: env.BRANCH_NAME
properties(
[
parameters([
string(name: 'GO_VERSION', description: 'Version of Go to use to build.'),
string(name: 'DOCKER_CLI_REPO', description: 'Docker CLI git source repository.'),
string(name: 'DOCKER_CLI_REF', description: 'Docker CLI reference to build from (usually a branch).'),
string(name: 'DOCKER_ENGINE_REPO', description: 'Docker Engine git source repository.'),
string(name: 'DOCKER_ENGINE_REF', description: 'Docker Engine reference to build from (usually a branch).'),
string(name: 'DOCKER_SCAN_REPO', description: 'Docker Scan git source repository.'),
string(name: 'DOCKER_SCAN_REF', description: 'Docker Scan reference to build from (usually a branch).'),
string(name: 'DOCKER_COMPOSE_REPO', description: 'Docker Compose git source repository.'),
string(name: 'DOCKER_COMPOSE_REF', description: 'Docker Compose reference to build from (usually a branch).'),
string(name: 'DOCKER_BUILDX_REPO', description: 'Docker Buildx git source repository.'),
string(name: 'DOCKER_BUILDX_REF', description: 'Docker Buildx reference to build from (usually a branch).'),
string(name: 'CONTAINERD_VERSION', description: 'Containerd version to build for the static packages. Leave empty to build the default version as specified in the Dockerfile in moby/moby.'),
string(name: 'RUNC_VERSION', description: 'Runc version to build for the static packages. Leave empty to build the default version as specified in the Dockerfile in moby/moby.'),
])
]
)
def pkgs = [
[target: "centos-7", image: "centos:7", arches: ["amd64", "aarch64"]], // (EOL: June 30, 2024)
[target: "centos-8", image: "quay.io/centos/centos:stream8", arches: ["amd64", "aarch64"]],
[target: "debian-buster", image: "debian:buster", arches: ["amd64", "aarch64", "armhf"]], // Debian 10 (EOL: 2024)
[target: "debian-bullseye", image: "debian:bullseye", arches: ["amd64", "aarch64", "armhf"]], // Debian 11 (Next stable)
[target: "fedora-34", image: "fedora:34", arches: ["amd64", "aarch64"]], // EOL: May 17, 2022
[target: "fedora-35", image: "fedora:35", arches: ["amd64", "aarch64"]], // EOL: November 30, 2022
[target: "fedora-36", image: "fedora:36", arches: ["amd64", "aarch64"]], // EOL: May 24, 2023
[target: "raspbian-buster", image: "balenalib/rpi-raspbian:buster", arches: ["armhf"]], // Debian/Raspbian 10 (EOL: 2024)
[target: "raspbian-bullseye", image: "balenalib/rpi-raspbian:bullseye", arches: ["armhf"]], // Debian/Raspbian 11 (Next stable)
[target: "ubuntu-bionic", image: "ubuntu:bionic", arches: ["amd64", "aarch64", "armhf"]], // Ubuntu 18.04 LTS (End of support: April, 2023. EOL: April, 2028)
[target: "ubuntu-focal", image: "ubuntu:focal", arches: ["amd64", "aarch64", "armhf"]], // Ubuntu 20.04 LTS (End of support: April, 2025. EOL: April, 2030)
[target: "ubuntu-impish", image: "ubuntu:impish", arches: ["amd64", "aarch64", "armhf"]], // Ubuntu 21.10 (EOL: July, 2022)
[target: "ubuntu-jammy", image: "ubuntu:jammy", arches: ["amd64", "aarch64", "armhf"]], // Ubuntu 22.04 LTS (End of support: April, 2027. EOL: April, 2032)
]
def genBuildStep(LinkedHashMap pkg, String arch) {
def nodeLabel = "linux&&${arch}"
def platform = ""
def branch = env.CHANGE_TARGET ?: env.BRANCH_NAME
if (arch == 'armhf') {
// Running armhf builds on EC2 requires --platform parameter
// Otherwise it accidentally pulls armel images which then breaks the verify step
platform = "--platform=linux/${arch}"
nodeLabel = "${nodeLabel}&&ubuntu"
} else {
nodeLabel = "${nodeLabel}&&ubuntu-2004"
}
return { ->
wrappedNode(label: nodeLabel, cleanWorkspace: true) {
stage("${pkg.target}-${arch}") {
// This is just a "dummy" stage to make the distro/arch visible
// in Jenkins' BlueOcean view, which truncates names....
sh 'echo starting...'
}
stage("info") {
sh 'docker version'
sh 'docker info'
}
stage("build") {
try {
checkout scm
sh "make REF=$branch ${pkg.target}"
} finally {
sh "make clean"
}
}
}
}
}
def build_package_steps = [
'static-linux': { ->
wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) {
stage("static-linux") {
// This is just a "dummy" stage to make the distro/arch visible
// in Jenkins' BlueOcean view, which truncates names....
sh 'echo starting...'
}
stage("info") {
sh 'docker version'
sh 'docker info'
}
stage("build") {
try {
checkout scm
sh "make REF=$branch DOCKER_BUILD_PKGS='static-linux' static"
} finally {
sh "make clean"
}
}
}
},
'cross-mac': { ->
wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) {
stage("cross-mac") {
// This is just a "dummy" stage to make the distro/arch visible
// in Jenkins' BlueOcean view, which truncates names....
sh 'echo starting...'
}
stage("info") {
sh 'docker version'
sh 'docker info'
}
stage("build") {
try {
checkout scm
sh "make REF=$branch DOCKER_BUILD_PKGS='cross-mac' static"
} finally {
sh "make clean"
}
}
}
},
'cross-win': { ->
wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) {
stage("cross-win") {
// This is just a "dummy" stage to make the distro/arch visible
// in Jenkins' BlueOcean view, which truncates names....
sh 'echo starting...'
}
stage("info") {
sh 'docker version'
sh 'docker info'
}
stage("build") {
try {
checkout scm
sh "make REF=$branch DOCKER_BUILD_PKGS='cross-win' static"
} finally {
sh "make clean"
}
}
}
},
]
def genPackageSteps(opts) {
return opts.arches.collectEntries {
["${opts.image}-${it}": genBuildStep(opts, it)]
}
}
build_package_steps << pkgs.collectEntries { genPackageSteps(it) }
parallel(build_package_steps)