Possible to create .env file with app env variables values inside?

Hi,
We are using react native with react-native-config. Unfortunately, it’s using .evn file to read variables from.

At this point (not being aware of alternatives how can i access env variables from react-native code) i’m trying to somehow generate .env file. However, it’s not possible to access env vars in scripts (ruby/bash).

Do you see any alternatives here?

1 Like

Hi @mxaly,

Thanks for asking this question here! :slight_smile:

Why is it not possible? The environment variables you can set in the Workflow Editor (e.g. App Env Vars and Secret Env Vars) are just regular environment variables, available for every step during the build.

Is there a specific limitation/tool why you can’t access environment variables?

@viktorbenei thanks for quick reply

You are right, the Environment Variables won't be replaced in this input. note made me think that they wont. I should be able then (by using for eg ruby script) to solve this.

thanks!

1 Like

In case of a Script step this might be confusing a bit indeed, but all this means is that the env vars won’t be replaced by the Bitrise CLI automatically, before passing the input to the Step, instead the content will be passed to the step “as it is”, and the step can decide whether it will expand the env vars.

In case of bash for example, bash will replace $ENV_VAR with its value, and in case of ruby ENV['ENV_VAR'] will give you the value of the ENV_VAR environment variable.

You can find more information about this at: http://devcenter.bitrise.io/getting-started/manage-your-bitrise-workflow/#environment-variable-replace-mode

Let us know if you have any questions! :wink: