Forum Stats

  • 3,875,392 Users
  • 2,266,909 Discussions
  • 7,912,190 Comments

Discussions

Build Pipeline | Can I hide the django SECRET_KEY from the repository?

daniel256
daniel256 Member Posts: 5 Green Ribbon

I am doing a build pipeline from a bitbucket repo, trying to build a simple django-app, and in the settings.py of the main folder there is in the code the SECRET_KEY=<secret>.

How can I hide the SECRET_KEY from the bitbucket repo but using it in the pipeline?

Tagged:

Best Answer

  • daniel256
    daniel256 Member Posts: 5 Green Ribbon
    Answer ✓

    Solved, i did the following

    in the dashboard of the build pipeline, in the parameters tab, set SECRET_KEY as a new parameter,

    paste in the build_spec.yaml that is used for the build pipeline, this will the SECRET_KEY as enviroment variable

    """

    env:

     variables:

       "SECRET_KEY": ${SECRET_KEY}

    """

    and put in the python file as following, that means is going to read to the os variables to get the secret key

    """

    import os

    SECRET_KEY = os.environ.get('SECRET_KEY')

    """

    VikK-Oracle

Answers

  • daniel256
    daniel256 Member Posts: 5 Green Ribbon
    Answer ✓

    Solved, i did the following

    in the dashboard of the build pipeline, in the parameters tab, set SECRET_KEY as a new parameter,

    paste in the build_spec.yaml that is used for the build pipeline, this will the SECRET_KEY as enviroment variable

    """

    env:

     variables:

       "SECRET_KEY": ${SECRET_KEY}

    """

    and put in the python file as following, that means is going to read to the os variables to get the secret key

    """

    import os

    SECRET_KEY = os.environ.get('SECRET_KEY')

    """

    VikK-Oracle