Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to use dotenv with Bitbucket Pipelines?

As the title says, is there any way to use dotenv with Bitbucket Pipelines for CI purposes, while still adding the (perhaps multiple) (.stage).env to .gitignore?

I know Pipeline supports environment variables, and that they can be referenced in bitbucket-pipelines.yml, but I can't figure out how to use dotenv files instead, and vary which file to use based on i.e. branch patterns.

For example, I'd like commits to develop to use .test.env variables, while commits to master instead uses the variables from .prod.env.

Perhaps I'm going down the wrong path? Although other websites use examples of multiple .env files, the library authors discourage that approach. I'm using Zeit Now for hosting, so I can't just SSH a .env file onto the server.

Any advice is very welcome :-)

like image 616
jhm Avatar asked Aug 13 '18 09:08

jhm


1 Answers

Rename the files inside your develop pipelines:

mv .test.env .env

or in your master pipelines:

mv .prod.env .env
like image 103
floflock Avatar answered Oct 24 '22 21:10

floflock