Last active
August 24, 2020 06:02
-
-
Save ToroNZ/360db135525e904a90471afe4b15a258 to your computer and use it in GitHub Desktop.
(python3) Get all ENV variables into JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| import json | |
| ENV_LIST = dict(os.environ.items()) | |
| VALUES = [{"key": k, "value": v, "secured": "true"} for k, v in ENV_LIST.items()] | |
| LOCAL_VARS = json.dumps(VALUES, indent=4) | |
| # Meant to be invoked in shell as '$ python3 env-to-json.py > local_vars.json' | |
| print(LOCAL_VARS) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Primarily to be used by Bitbucket pipelines before using 'pipe'.