.gitlab-ci.yml supports 'image' to allow selecting in which environment the script gets run. The documentation says "Used to specify a Docker image to use for the job", but it's clearly a bug in the documentation, because we can do it with nspawn-runner, too.
It turns out that most of the environment variables available to CI runs
are also available to custom runner scripts. In this case, the value passed as
image
can be found as $CUSTOM_ENV_CI_JOB_IMAGE
in the custom runner scripts
environment.
After some experimentation I made this commit
that makes every chroot under /var/lib/nspawn-runner
available as an image:
# Set up 3 new images for CI jobs:
nspawn-runner chroot-create buster
nspawn-runner chroot-create bullseye
nspawn-runner chroot-create sid
That's it, CI scripts can now use image: buster
, image: bullseye
or image:
sid
, as they please. You can manually set up other chroots under
/var/lib/nspawn-runner
and they'll be automatically available.
You can also now choose a default image in config.toml
in case the CI script
doesn't specify one:
prepare_args = ["--verbose", "prepare", "--default-image=buster"]
Updated:
- New step! taking advantage of btrfs features, if available