Created
June 28, 2024 04:14
-
-
Save minuz/aaca7424422f5b4a6726c006f0f6380d to your computer and use it in GitHub Desktop.
Replace Pipeline environment 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
| #!/bin/bash | |
| # Initialize empty JSON object | |
| json_object="{}" | |
| # Loop through pipeline variables starting with VITE_ | |
| for var_name in "${!VITE@}"; do | |
| # Check if variable starts with VITE_ (avoids unrelated variables) | |
| if [[ $var_name =~ ^VITE_ ]]; then | |
| # Extract variable value | |
| var_value=${!var_name} | |
| # Build JSON key-value pair directly using JQ | |
| json_object=$(echo "$json_object" | jq '. + {"'"$var_name"'": "'"$var_value"'"}') | |
| fi | |
| done | |
| # Save JSON object to file | |
| echo "$json_object" > app-start/app.settings.json | |
| echo "Successfully created app-start/app.settings.json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment