0

I am aware that we don't commit .env file to GIT since it contains secret password of the application. Now, my question is that how come our code via CICD pipeline for this project repository will run in production without having this .env file? Because in our python file inside the project, we will be referring the secrets from this .env file and since it will not be in GIT, pipeline will fail, isn't it? For example, let's say below is the class which uses dotenv function, but since we will not check in .env file in GIT, won't this fail in CICD pipeline run saying .env file not found?

# settings.py
import os
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

SECRET_KEY = os.environ.get("SECRET_KEY")
DATABASE_PASSWORD = os.environ.get("DATABASE_PASSWORD")
torek
  • 448,244
  • 59
  • 642
  • 775

1 Answers1

0

I found this, on how to pass secrets in the build pipeline.

https://tsi-ccdoc.readthedocs.io/en/master/ResOps/2019/gitlab/07_pass-build-secrets.html

  • Well, why would I be using if else statement since I need those variables in all conditions? What's the use of code running if I skip these variables? – Sumit Dwivedi Jan 27 '22 at 00:55
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Felix Arnold Jan 27 '22 at 08:35
  • I am surprised that no one is able to answer this question yet – Sumit Dwivedi Jan 28 '22 at 06:30