From 47d8eb18abded10c990d84b6a63d0d0d86876a48 Mon Sep 17 00:00:00 2001
From: Gcolon021 <34667267+Gcolon021@users.noreply.github.com>
Date: Fri, 18 Aug 2023 16:42:54 -0400
Subject: [PATCH] ALS 4884 google analytics (#73)
* [ALS-4884] Improve Google Analytics Job
---
.../jobs/Configure Google Analytics/config.xml | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/initial-configuration/jenkins/jenkins-docker/jobs/Configure Google Analytics/config.xml b/initial-configuration/jenkins/jenkins-docker/jobs/Configure Google Analytics/config.xml
index b05c4123..1ecf5d0e 100644
--- a/initial-configuration/jenkins/jenkins-docker/jobs/Configure Google Analytics/config.xml
+++ b/initial-configuration/jenkins/jenkins-docker/jobs/Configure Google Analytics/config.xml
@@ -24,9 +24,22 @@
false
- export old_analytics_id=`cat /usr/local/docker-config/httpd/picsureui_settings.json | grep analytics_id | cut -d ':' -f 2 | sed 's/\",*//g'`
+ #!/bin/bash
- sed -i "s/$old_analytics_id/ANALYTICS_ID/g" /usr/local/docker-config/httpd/picsureui_settings.json
+ # If the $ANALYTICS_ID variable is blank, set it to __ANALYTICS_ID__
+ : ${ANALYTICS_ID:="__ANALYTICS_ID__"}
+
+ # Check for the presence of the analytics_id key and fetch its value
+ value=$(jq -r 'select(.analytics_id != null) | .analytics_id' /usr/local/docker-config/httpd/picsureui_settings.json)
+
+ # Check if the key is missing
+ if [[ -z $value ]]; then
+ # Add the analytics_id key with value of $ANALYTICS_ID
+ jq --arg ANALYTICS_ID "$ANALYTICS_ID" '. + {"analytics_id": $ANALYTICS_ID}' /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 with the value of $ANALYTICS_ID
+ jq --arg ANALYTICS_ID "$ANALYTICS_ID" '.analytics_id = $ANALYTICS_ID' /usr/local/docker-config/httpd/picsureui_settings.json > /tmp/temp.json && mv /tmp/temp.json /usr/local/docker-config/httpd/picsureui_settings.json
+ fi