From 73e572877c6f77a907ba7838f67e22db88d6fd7c Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Oct 2023 16:03:43 -0400 Subject: [PATCH] [ALS-5177] Create job for editing and adding settings (#87) * Create job for editing and adding settings --- .../jobs/Add or Edit a Setting/config.xml | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 initial-configuration/jenkins/jenkins-docker/jobs/Add or Edit a Setting/config.xml diff --git a/initial-configuration/jenkins/jenkins-docker/jobs/Add or Edit a Setting/config.xml b/initial-configuration/jenkins/jenkins-docker/jobs/Add or Edit a Setting/config.xml new file mode 100644 index 00000000..121e3ba0 --- /dev/null +++ b/initial-configuration/jenkins/jenkins-docker/jobs/Add or Edit a Setting/config.xml @@ -0,0 +1,52 @@ + + + + Edit the values in picsureui_settings.json file. You can find the current file in either your Network tab of your browser's developer tools by searching for "settings.json" or in this location: /usr/local/docker-config/httpd/picsureui_settings.json + false + + + + + SETTING_FIELD_NAME + The field name of the setting you would like to edit. Example: helpLink + + false + + + SETTING_VALUE + The value of the setting. This can be a string or json object. NOTE: If it is a string is should be in quotes. For more complex values you may need run it through a json linter. Example: "mailto:example@example.com" OR {"hello": "world", "arrayName": ["array", "test"]} + + false + + + + + + true + false + false + false + + false + + + + #!/bin/bash + # Check for the presence + current_field_name=$(jq -r --arg field_name "$SETTING_FIELD_NAME" 'select(.[$field_name] != null) | .[$field_name]' /usr/local/docker-config/httpd/picsureui_settings.json) + echo $current_field_name + + # Check if the key is missing + if [[ -z $current_field_name ]]; then + # Add the key with the value + jq --arg field_name "$SETTING_FIELD_NAME" --argjson value "$SETTING_VALUE" '. + {($field_name): $value}' /usr/local/docker-config/httpd/picsureui_settings.json > /tmp/temp.json && mv /tmp/temp.json /usr/local/docker-config/httpd/picsureui_settings.json + else + # Replace the old value + jq --arg field_name "$SETTING_FIELD_NAME" --argjson value "$SETTING_VALUE" '.[$field_name] = $value' /usr/local/docker-config/httpd/picsureui_settings.json > /tmp/temp.json && mv /tmp/temp.json /usr/local/docker-config/httpd/picsureui_settings.json + fi + + + + + +