-
Notifications
You must be signed in to change notification settings - Fork 0
Using k.d.d with a CI solution
The Koha debs docker provides a streamlined solution for building Koha packages - which opens up the obvious opportunity for generating such packages in a CI pipeline. That's exactly what Open Fifth is doing over on the Koha Community Jenkins suite. The basic process is to seed a few environment variables, and then use a Perl script to run through the process. Let me explain in more detail!
Please also note: You will need a valid clone of Koha for this to work. By using a CI suite, I'm going to presume the source code is handled without human interaction. If you do need to clone the source code, please take a read of Cloning with git first.
Before we get going, you're going to need to actually test your codebase. This can be done in a rather efficient manner using the Koha testing docker - the architecture of which I have intentionally kept this k.d.d analogous to.
The k.t.d can be pulled from DockerHub, and a script is present to run it within a CI environment - maintained by the Koha Community. To get started, try out the following (assuming you are using Jenkins, with docker-compose installed):
#!/bin/bash -x
## cd kohaclone
cd ${WORKSPACE}/kohaclone
export SYNC_REPO="${WORKSPACE}/kohaclone"
export KOHA_IMAGE="22.11-bullseye"
export KTD_BRANCH="22.11"
export LIGHT_RUN=1
## build ktd
wget -O build.pl https://gitlab.com/koha-community/koha-testing-docker/-/raw/${KTD_BRANCH}/jenkins_config/build.pl
/usr/bin/perl build.plRunning this in a Jenkins pipeline, or freestyle project, will result (provided the branch you pick is stable) in a passing build! With that, we can move on to actually building within the CI suite.
With a passing testing suite, we can now be confident that any packages we build are suitable for a production environment. In a pipeline, this would obviously come as a different build step - that is the assumption I will make in this guide. If you're using a freestyle project, you can just daisy-chain the scripts together in one execution to gain the desired effect.
Stepping into the mud of it, we have yet another build.pl, this time for k.d.d! To run it, simply add the following to your pipeline, under a build step:
#!/bin/bash -x
## cd kohaclone
cd ${WORKSPACE}/kohaclone
export SYNC_REPO="${WORKSPACE}/kohaclone"
export DEBS_OUT="${WORKSPACE}/kohadebs"
export KDD_IMAGE="22.11"
export KDD_BRANCH="22.11"
## build kdd
wget -O build.pl https://github.com/openfifth/koha-debs-docker/-/raw/${KDD_BRANCH}/jenkins_config/build.pl
/usr/bin/perl build.plThe build.pl script, like before with k.t.d, will handle everything. All you need to do is provide the tool with the correct image and branch code - it's pretty much that simple.
There are a few minor caveats: you need to be cd'd into the root directory of the git clone. This is so the git clean -f command within build.pl can operate correctly. You also need to make sure that the path to the DEBS_OUT variable is empty, and writable by the CI user. If it isn't, the build will run, but you won't get any artefacts!
Other than those small things, that's pretty much all there is to it. Give it a try - and feed back if it doesn't work in your CI suite. We've only tested this in Jenkins, but we love feedback <3