In my local.conf I have the following variables defined:
MACHINE ?= "default"
# Version variables overriden by CI/CD
CI_COMMIT_BRANCH ?= "local"
BUILD_VERSION ?= "v0.0.0"
CI_COMMIT_SHORT_SHA ?= "local version"
In a recipe (custom-fit-image.bb) I use these variables:
python do_image_complete() {
machine = d.getVar('MACHINE', expand=True)
version_tag = d.getVar('BUILD_VERSION', expand=True)
branch_type = d.getVar('CI_COMMIT_BRANCH', expand=True)
git_short_hash = d.getVar('CI_COMMIT_SHORT_SHA', expand=True)
bb.note(f"MACHINE: {machine}; BUILD_VERSION: {version_tag};CI_COMMIT_BRANCH: {branch_type};CI_COMMIT_SHORT_SHA: {git_short_hash}")
....
....
}
addtask do_image_complete before do_populate_sysroot after do_install
When I call bitbake from the cmdline I want to override them like this:
MACHINE=my_machine CI_COMMIT_BRANCH=bli BUILD_VERSION=bla CI_COMMIT_SHORT_SHA=blub bitbake custom-fit-image
However only MACHINE get's overriden. Here the output of the bb.note call of the do_image_complete function:
NOTE: MACHINE: my_machine; BUILD_VERSION: v0.0.0;CI_COMMIT_BRANCH: local;CI_COMMIT_SHORT_SHA: local version
Why is only MACHINE overriden and how can I override the other variables? The only difference I can see is that MACHINE is a standard yocto variable used in a lot of places and the other variables are my custom ones. But still they are defined in the same file and I try to override them in the same manner. So I'm a bit confused.
Have a look in the bitbake manual at BB_ENV_PASSTHROUGH_ADDITIONS:
You will see the default scripts/oe-buildenv-internal script sets BB_ENV_PASSTHROUGH_ADDITIONS_OE to include MACHINE, DISTRO, TCMODE, TCLIBC, HTTP_PROXY, http_proxy and a few more.