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 ...
```
This commit is contained in:
2025-12-01 20:42:52 -06:00
parent b98e6a99ae
commit 3d17d1bba4

View File

@@ -10,6 +10,7 @@ def call(args) {
def defaultBranch = args?.defaultBranch
def pi = args?.pi
def resources = args?.resources
def buildArgs = args?.buildArgs
properties([
pipelineTriggers([cron(schedule ?: 'H H H * *')])
@@ -47,6 +48,7 @@ def call(args) {
registry: registry,
arch: arch,
resources: resources,
buildArgs: buildArgs,
)
}
}
@@ -95,13 +97,18 @@ def buildStage(args) {
def registry = args.registry
def arch = args.arch
def resources = args?.resources
def buildArgs = args?.buildArgs ?: []
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"
}