Determining build target settings at build time

I’m trying to use the BUILD_BALENA_MACHINE_NAME parameter in my Dockerfile.template and in my CMakefile.txt:

FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu:bionic-build


and in CMakeLists.txt


but now I’m getting:

git push balena
Enumerating objects: 118, done.
Counting objects: 100% (118/118), done.
Delta compression using up to 4 threads
Compressing objects: 100% (91/91), done.
Writing objects: 100% (91/91), 28.00 KiB | 2.00 MiB/s, done.
Total 91 (delta 72), reused 0 (delta 0)

[Info]         Starting build for rv-camera-rpi3b, user oldmacdonald
[Info]         Dashboard link:
[Error]        Could not detect project type: Service camera: BUILD_BALENA_MACHINE_NAME is not defined
[Error]        Not deploying release.

remote: error: hook declined to update refs/heads/master
 ! [remote rejected] master-> master (hook declined)
error: failed to push some refs to ''

How did I break my app?

Hi, do you mean BALENA_MACHINE_NAME?

Sorry, misread the text. Looking into it.

I think you should use ARG instead of ENV, because BALENA_MACHINE_NAME is the build variable.

Yes, I should have used “BALENA_MACHINE_NAME” on the right side of the ENV variable definition in my Dockerfile.template:

FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu:bionic-build

and the CMakeLists.txt as above. Sorry for the confusion. Now that I look at my question I see the error.