Compare commits

2 Commits

Author SHA1 Message Date
3d17d1bba4 bci2: Add buildArgs argument
The `buildArgs` argument to `buildContainerImage2` accepts a list of
arguments that will be passed as `--build-arg` values to the `buildah
build` command.  For example,

```groovy
buildContainerImage2(buildArgs: ['FOO=bar'])
```

Would result in a command like

```sh
buildah build --build-arg FOO=bar ...
```
2025-12-01 20:44:24 -06:00
b98e6a99ae bci2: Add resources argument
Instead of a top-level boolean that says whether or not the build
can/should run on a Raspberry Pi, we'll expose a `resources` argument
that allows jobs to specify their compute requirements.  If they're not
specified, then the job can run anywhere.  Otherwise, if the
requirements are too large for a Pi, then the autoscaler will launch a
cloud worker to handle the build.
2025-09-26 10:16:26 -05:00

View File

@@ -9,6 +9,8 @@ def call(args) {
def schedule = args?.schedule
def defaultBranch = args?.defaultBranch
def pi = args?.pi
def resources = args?.resources
def buildArgs = args?.buildArgs
properties([
pipelineTriggers([cron(schedule ?: 'H H H * *')])
@@ -32,9 +34,6 @@ def call(args) {
if (defaultBranch == null) {
defaultBranch = 'main'
}
if (pi == null) {
pi = true
}
def repo = "${registry}/${project}/${name}"
def full_name = "${repo}:${tag}"
@@ -48,14 +47,15 @@ def call(args) {
full_name: full_name,
registry: registry,
arch: arch,
pi: pi,
resources: resources,
buildArgs: buildArgs,
)
}
}
}
parallel stages
runInPod(pi: false) {
runInPod {
container('buildah') {
withBuildahCreds(registry) {
if (archlist.size() > 1) {
@@ -96,14 +96,19 @@ def buildStage(args) {
def full_name = args.full_name
def registry = args.registry
def arch = args.arch
def pi = args.pi
def resources = args?.resources
def buildArgs = args?.buildArgs ?: []
runInPod(arch: arch, pi: pi) {
def build_command = "buildah build -t '${full_name}'"
buildArgs.each { build_command += "--build-arg '${it}'" }
build_command += ' .'
runInPod(arch: arch, resources: resources) {
checkout scm
container('buildah') {
withBuildahCreds(registry) {
sh "buildah build -t '${full_name}' ."
sh build_command
sh "buildah push '${full_name}' oci-archive:\${PWD}/${escapeImageName(name)}-${arch}.tar:${full_name}"
stash name: arch, includes: "${escapeImageName(name)}-*.tar"
}
@@ -111,23 +116,24 @@ def buildStage(args) {
}
}
def runInPod(block) {
runInPod(null, block)
}
def runInPod(args, block) {
def arch = args?.arch
def pi = args?.pi
if (pi == null) {
pi = true
}
def resources = args?.resources
def podTemplateYaml = libraryResource('podTemplate2.yaml')
if (pi) {
if (resources) {
def tmpl = readYaml(text: podTemplateYaml)
def tolerations = tmpl['spec']['tolerations'] ?: []
tolerations.push([
key: 'du5t1n.me/machine',
value: 'raspberrypi',
effect: 'NoExecute',
tmpl.spec.containers.each { c ->
c.resources = c.resources ?: [:]
c.resources.putAll([
requests: (c.resources.requests ?: [:]) + resources,
limits: (c.resources.limits ?: [:]) + resources,
])
tmpl['spec']['tolerations'] = tolerations
}
podTemplateYaml = writeYaml(data: tmpl, returnText: true)
}
podTemplate(