Load environment variables from a file

In Skaffold, a skaffold.env file can be defined in the project root directory to specify environment variables that Skaffold will load into the process. This provides a more organized and manageable way of setting environment variables, rather than passing them as command line arguments.

The skaffold.env file should be in the format of KEY=value pairs, with one pair per line. Skaffold will automatically load these variables into the environment before running any commands.

Here is an example skaffold.env file:

ENV_VAR_1=value1
ENV_VAR_2=value2

Setting Skaffold Flags with Environment Variables

In addition to loading environment variables from the skaffold.env file, Skaffold also allows users to set flags using environment variables. To set a flag using an environment variable, use the SKAFFOLD_ prefix and convert the flag name to uppercase.

For example, to set the --cache-artifacts flag to true, the equivalent environment variable would be SKAFFOLD_CACHE_ARTIFACTS=true.

Here is an example usage in the skaffold.env file:

SKAFFOLD_CACHE_ARTIFACTS=true
SKAFFOLD_NAMESPACE=mynamespace