Howto: MENDER_ARTIFACT_NAME automatic setup for yocto build

There was already discussion about setting automatics ARTIFACT_NAME in old google forum just want to share how I did it (maybe someone will find it handy).

Basically I’ve setup in local.conf

MENDER_ARTIFACT_NAME ?= "release-1"

this variable have weak preference so our set with environment will be used (if we don’t use one in env default release-1 will be used).
Then in build script I set:

export MENDER_ARTIFACT_NAME="$version"
export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE MENDER_ARTIFACT_NAME"

where $version is desired version (we use it from runner like date_time_machine…)

finally build then image like usual and mender artifact will have then version used in MENDER_ARTIFACT_NAME variable. Comments? Thanks.

4 Likes

Hi,

I’m looking at the same problem, ie. injecting the artifact name from the CI. The drawback of using external environment variables is that it causes Bitbake to re-parse everything, which is pretty slow.

I was considering just using mender-artifact to set the artifact name as a post-build step, but unfortunately it can’t (AFAIK) manipulate the sdimg image files produced by Bitbake.

1 Like

@andersm welcome. Well it’s kind of true only when variable is changed. I’m not aware of any easy way of manipulating artifact name only by updating variable (would be possible though by some special way adding custom image step to update artifact name after build is done).

Recently had to do this too, found it helpful to have IMAGE_BASENAME := "${MENDER_ARTIFACT_NAME}" as well so that my sdimg artifact also had the name of the artifact.

Also can recommend using kas for managing the Yocto build and injecting variables for this sort of thing. It’s a really nice tool.

1 Like

Shouldn’t it be IMAGE_BASENAME += ... ?
I like kas also :slight_smile: