Forward Environment Variables
--env passes an environment variable of the host into a VM instance, so a
build or a script inside the guest can read it without the value ever being
written to disk in the guest.
This page is about variables you pass into a guest. Cubic also reads variables
of the host for its own settings, such as CUBIC_QEMU_DIR and the proxy of
the image download. Environment Variables lists all of them.
Forward a Variable of the Host
Pass the variable by name and Cubic reads its value from your host environment:
$ export GITHUB_TOKEN=ghp_yourTokenHere
$ cubic ssh builder --env GITHUB_TOKEN
Confirm inside the guest that the value arrived:
$ echo $GITHUB_TOKEN
ghp_yourTokenHere
The variable exists for the length of the session only.
Pass an Explicit Value
Use KEY=VALUE when the value is not set on the host:
$ cubic ssh builder --env BUILD_TARGET=release
Both forms can be repeated and combined:
$ cubic ssh builder --env GITHUB_TOKEN --env BUILD_TARGET=release
Use It for a Build
A forwarded token lets a build fetch private dependencies without storing the token in the guest:
$ git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
$ pip install git+https://github.com/your-org/private-lib.git
Run a One-Off Command
cubic exec takes the same flag and needs no interactive shell:
$ cubic exec builder --env GITHUB_TOKEN -- pip install git+https://github.com/your-org/private-lib.git