Usage¶
How to create your own CI configuration¶
Here are the steps to follow in order to define your own custom build:
- Create a branch in the Git repository to hold your customization
- Write the CI configuration file (
.gitlab-ci.yml) - Define optional trigger rules (
.ci-trigger.yml)
Git repository branch¶
Our first step is to create, or locate, a branch where we will be hosting our CI configuration. Following the default and recommended naming conventions:
git clone https://gitlab.com/witekio/rnd/theembeddedkit/welma/ci.git
cd ci
git checkout --orphan config/username/main
CI configuration file¶
In our custom branch, we want to create the standard .gitlab-ci.yml file, holding the instructions for the CI:
Here is a template declaring and declining a standard Yocto BSP build for two machines:
Notes
- For an explanation of the syntax, review the official GitLab documentation.
- The
.build-yoctoentry will not be recognized as a CI job. It is thus used as a template to decline the build forqemuarm64andqemuarmmachines through the use of theextendskeyword. - Entries under
variablesare exposed as environment variables thus saving us the need to manually exportMACHINE,DISTRO, andTEMPLATECONFin thescriptsection. - Jobs (i.e.:
build:qemuarm64, andbuild:qemuarm) are independent from each other: they will run in parallel by default and not necessarily on the same machine.
CI configuration use case: Welma¶
For a Welma-specific build, we suggest to start from the main CI configuration
branch of our
config/minimal
release.From the
.gitlab-ci.yml
there, you will note…
… the inclusion of a /snippet/common.yml file:¶
This will include the content of the
snippets/common.yml file
located in the default branch of this repository. It allows us to create reusable defaults for most operations. Currently, you will find various helpers
(.snippets)
to setup Git and OpenSSH for the container environment in the CI environment.
Those helpers are currently used as part of the scripting of jobs, referenced by using the !reference […] tag.
You can also read more about the include keyword in the official documentation.
… the tagging of the jobs to specific runners:¶
This ensures that the jobs run on our special autoscaling AWS runners, where we configured a shared folder between runners, for build-time optimization purposes.… use of external folders for DL_DIR and SSTATE_DIR:¶
We use the standard site.conf configuration file to set a custom location for the downloads and sstate folders of bitbake. Our AWS runners provide a persistent and concurrently accessible /shared folder: a container-specific volume mounted from the host machine, as per definition in
the runner's configuration.
Trigger rules¶
In our custom branch, we can also create a custom .ci-trigger.yml file, holding a limited subset of GitLab CI definitions, to condition the scheduling of this branch for automatic building.
About the default behavior without trigger rules:
Not providing a trigger rules file will make this CI configuration branch always execute upon trigger from an external repository.
We do not recommend this practice as it may waste resources since the change which triggered the build may be related to code unused in your custom build.
This file should contain a rules keyword definition:
An example can be found in our
config/minimal
branch:
Upon trigger of the CI from an external repository, if the event comes from a repository named
meta-welmaand in thekirkstone-nextbranch, then schedule the build of this configuration branch. This ensures that the build configuration in ourconfig/minimalbranch matches changes made intometa-welmain thekirkstone-nextbranch.
How to trigger builds¶
Here are the few ways the pipeline described in your CI configuration can be triggered:
- Automatically, through our custom trigger system.
- Manually through the GitLab UI in a repository implementing our trigger system (e.g. from
meta-welma), from the sidebar:Build -> Pipelines -> Run Pipelineand select your Git branch before pushing theRun Pipelinebutton. - Manually through the GitLab UI,
from the sidebar:
Build -> Pipelines -> Run Pipelineand select your Git branch before pushing theRun Pipelinebutton. - Manually through the
glabCLI:glab ci run --branch <name>. - Manually, using the Pipeline API.