Created
August 3, 2023 23:07
-
-
Save matchaxnb/0a1ac7ea256fc3c2745166413fe8ad1e to your computer and use it in GitHub Desktop.
GitLab JSON variables to POSIX shell variables
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 python | |
"""jsontovars.py: parse GitLab API /projects/<id>/variables endpoint and export as shell variables""" | |
import sys | |
import json | |
data = json.load(sys.stdin) | |
for item in data: | |
if item['variable_type'] != 'env_var': | |
continue | |
print(f"""export {item['key']}="{item['value']}" """) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment