Closed HerrMuellerluedenscheid closed 3 years ago
Have a look at env
from https://kas.readthedocs.io/en/latest/userguide.html#project-configuration.
This seems to become a FAQ. Suggestions how to improve to manual to make this easier findable are welcome.
Thanks @jan-kiszka! Not sure why I overlooked this part.
In case others stumble across the same issue: To make the example from above work, simply put an env
block with defaults into your configuration (just as the documentation points out). In the upper case that would be:
env:
WANT_TARGET_BRANCH = master
Then, invoke kas as follows to set WANT_TARGET_BRANCH
from the command line:
kas shell dev.yml -c "WANT_TARGET_BRANCH=X bitbake my_tool"
Hope this little example helps others.
have the same issue and can't seem to get it working with kas-container:
i need to pass a timestamp into yocto so a variable is set and only evaluated once, e.g.
MENDER_ARTIFACT_NAME="${IMAGE_BASENAME}-${MACHINE}-${@time.strftime('%Y%m%d%H%M%S', time.gmtime())}"
would not work as it changes during the build as its re-evaluated multiple times so i'd need to pass a value in from the outside (e.g. CI), is this supported by kas?
@simonbuehler Your particular issue should resolvable via immediate expansion (https://docs.yoctoproject.org/bitbake/2.2/bitbake-user-manual/bitbake-user-manual-metadata.html#immediate-variable-expansion).
Unfortunately not, it evaluates it as soon as it parses that line, but it may still be evaluated multiple times, any other way to pass a variable value from outside?
@jan-kiszka thanks for your input, for now i have a solution as outlined in #28 but i'd prefer not to use env but rather a parameter passed in for CI usage
We generally recommend CI parametrization via env vars, though. What issues do you see with it? Yeah, kas-container cannot parse the complete kas config hierarchy, thus needs help via --runtime-args "-e var=value"
.
Well after a second thought its actually a no-issue with the env vars passed this ways, so handling it like ./kas/kas-container --runtime-args "-e BUILD_TIMESTAMP=$(date +%Y%m%d%H%M%S)" --ssh-dir ~/.ssh/ build kas-mydistro/distro.yml
works for me, thanks for the hint!
Hey, I'm trying to set an environment variable from the command line. In one of my recipes I set:
How can I set that variable when calling kas? Would come very handy in my CI pipeline. I tried something like
and
Neither was working so far. Best