We will setup a Yocto build server with Jenkins. Lets not talk about it too much lets just get too work. I am using a Ubuntu 24.04 server and to resolve conflicts I will use Docker. Here is a post I made how to install docker.
We will use a Beagle Bone Black (BBB) as the hardware. Its easily available and relatively cheap and decently powerful. Its widely available as well.
What we will get:
Jenkins (controller) in Docker
Yocto build agent in Docker using scarthgap
Shared caches on host:
/yocto/sstate-cache
/yocto/downloads
/yocto/workspace
Here is a folder structure that you will see
/<path to your folder>/yocto/
├── docker-compose.yml
├── downloads/
├── sstate-cache/
└── workspace/
├── sources/
└── build/
Target: MACHINE = "beaglebone" on scarthgap with meta-beagle + meta-ti-bsp.
1. Host prep (once on VPS)
sudo mkdir -p yocto/{sstate-cache,downloads,workspace}
sudo chmod -R yocto
cd yocto
touch docker-compose.yml
nano docker-compose.yml
Once you are have the file open paste the content below in the compose file.
2. docker-compose.yml (scarthgap‑ready)
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins-controller
restart: unless-stopped
user: root
ports:
- "8080:8080"
- "50000:50000"
volumes:
- jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
yocto-agent:
image: ubuntu:22.04
container_name: jenkins-yocto-agent
restart: unless-stopped
privileged: true
shm_size: "16g"
volumes:
- ./yocto/sstate-cache:/sstate-cache
- ./yocto/downloads:/downloads
- ./yocto/workspace:/workspace
command: tail -f /dev/null
volumes:
jenkins_home:
Now you can start the docker container by using the command below
docker compose up -d
3. Inside the Yocto agent: toolchain + scarthgap checkout
Next lets get inside the docker container when it starts running with the command below. This will give us the containers terminal.
docker exec -it jenkins-yocto-agent bash
Let’s install all the build dependencies
apt update
apt install -y \
gawk wget git diffstat unzip texinfo gcc-multilib build-essential \
chrpath socat cpio python3 python3-pip python3-pexpect xz-utils \
debianutils iputils-ping libsdl2-dev xterm locales sudo \
openjdk-17-jre
Clone scarthgap + BBB layers into /workspace/sources:
cd /workspace
mkdir -p sources && cd sources
# Poky (scarthgap)
git clone -b scarthgap git://git.yoctoproject.org/poky
# OpenEmbedded
git clone -b scarthgap git://git.openembedded.org/meta-openembedded
# TI + Beagle
git clone -b scarthgap git://git.yoctoproject.org/meta-ti
4. First manual Yocto setup (to “bake in” config)
cd /workspace
source sources/poky/oe-init-build-env build-bbb
build-bbb/
├── conf/
│ ├── bblayers.conf
│ └── local.conf
├── tmp/
├── sstate-cache/ (if local)
└── cache/
Edit conf/bblayers.conf to include:
BBLAYERS ?= " \
/workspace/sources/poky/meta \
/workspace/sources/poky/meta-poky \
/workspace/sources/poky/meta-yocto-bsp \
/workspace/sources/meta-openembedded/meta-oe \
/workspace/sources/meta-openembedded/meta-python \
/workspace/sources/meta-openembedded/meta-networking \
/workspace/sources/meta-openembedded/meta-multimedia \
/workspace/sources/meta-ti/meta-ti-bsp \
/workspace/sources/meta-ti/meta-beagle \
"
Set conf/local.conf:
MACHINE ?= "beaglebone"
SSTATE_DIR ?= "/sstate-cache"
DL_DIR ?= "/downloads"
BB_NUMBER_THREADS = "44"
PARALLEL_MAKE = "-j44"
INHERIT += "ccache"
CCACHE_DIR = "/workspace/ccache"
Quick sanity build (optional but recommended):
cd /workspace/build-bbb
bitbake core-image-minimal
5. Jenkins: node + label
In Jenkins UI:
yocto-agent/workspaceyocto-bbbIf you use SSH, run an SSH server in the agent container; if you use JNLP, download the agent jar and run it inside the container.
6. Jenkinsfile for BBB + scarthgap
Create a Jenkinsfile in your Yocto platform repo (or a freestyle pipeline using this):
pipeline {
agent { label 'yocto-bbb' }
environment {
YOCTO_TOP = "/workspace"
BUILD_DIR = "${YOCTO_TOP}/build-bbb"
MACHINE = "beaglebone"
TARGET = "core-image-minimal"
}
stages {
stage('Env info') {
steps {
sh 'uname -a'
sh 'nproc'
}
}
stage('Prepare build env') {
steps {
sh """
cd ${YOCTO_TOP}
source sources/poky/oe-init-build-env ${BUILD_DIR}
bitbake-layers show-layers
"""
}
}
stage('Build image') {
steps {
sh """
cd ${YOCTO_TOP}
source sources/poky/oe-init-build-env ${BUILD_DIR}
bitbake ${TARGET}
"""
}
}
stage('Archive artifacts') {
steps {
archiveArtifacts artifacts: "${BUILD_DIR}/tmp/deploy/images/${MACHINE}/*", fingerprint: true
}
}
}
}
7. Where your BBB images will land
After a successful build:
/workspace/build-bbb/tmp/deploy/images/beaglebone/
You’ll see .wic, .tar.xz, u-boot, kernel, etc.—ready to flash.
Leave a Reply