1

Stuck with Bitbucket pipelines.

In my code i have some secret info

apiKey: process.env.apiKey,
authDomain: process.env.authDomain

But bitbucket pipeline during build can't access them.
Have set up variables via Bitbucket Env variables UI

In yml file i can access variables via $Variable, but how to do this with code?
Thanks

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Андрей Гузюк
  • 2,134
  • 6
  • 29
  • 53
  • Possible duplicate of [Can I access Bitbucket Pipelines environment variables from my source code?](https://stackoverflow.com/questions/45917906/can-i-access-bitbucket-pipelines-environment-variables-from-my-source-code) – zero298 Nov 03 '17 at 20:11
  • 1
    Just as a sanity check, add `console.log(process.env)` in your code to check whether the variables are there. – zero298 Nov 03 '17 at 20:12

2 Answers2

1

You can set up environment variables in Bitbucket, and access them via $variableName in the YAML build file.

Bitbucket uses the environment variables recorded in Bitbucket when running your build pipeline. But it only does this inside your YAML build file. It won't do anything with environment variables referenced in the rest of your code.

For the rest of your codebase, environment variables are worked out on the hosting server at runtime. So if you use environment variables elsewhere in your code (e.g. in your app.js), you need to configure these in your hosting environment.

martinlugton
  • 81
  • 1
  • 3
0

This should provide more context for your use case - bitbucket docummentation

  • Create the environment variable in your env file
  • use $ENV_NAME to access your specified variable
Favour George
  • 1,525
  • 13
  • 18