From 0ad5217ff5516f6a8101df3d878f81f9500f8ac0 Mon Sep 17 00:00:00 2001 From: Emmanuel Nyachoke Date: Wed, 31 Jan 2024 08:01:03 +0300 Subject: [PATCH] INFRA-427: Update the existing ENVs check to avoid matching unwanted ENVs --- jenkins/jenkins_home/config.xml | 2 +- node-scripts/spec/pipeline3/scripts.spec.js | 2 +- node-scripts/src/pipeline3/scripts.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jenkins/jenkins_home/config.xml b/jenkins/jenkins_home/config.xml index f1bfd28..e4def5c 100644 --- a/jenkins/jenkins_home/config.xml +++ b/jenkins/jenkins_home/config.xml @@ -1,7 +1,7 @@ - 2.387.3 + 2.426.3 2 NORMAL true diff --git a/node-scripts/spec/pipeline3/scripts.spec.js b/node-scripts/spec/pipeline3/scripts.spec.js index 3ec4263..3098492 100644 --- a/node-scripts/spec/pipeline3/scripts.spec.js +++ b/node-scripts/spec/pipeline3/scripts.spec.js @@ -419,7 +419,7 @@ describe("Scripts", function() { var filename = ".env"; expect(scripts.writeProperty(envVar, value, filename)).toEqual( - 'if ! grep -R "^[#]*s*KEY.*" .env > /dev/null; then\n' + + 'if ! grep -w "KEY" .env > /dev/null; then\n' + "\techo \"'KEY' is not found in file '.env'. Appending...\"\n" + '\techo "KEY=a/path/on/the/disk" >> .env\n' + "else\n" + diff --git a/node-scripts/src/pipeline3/scripts.js b/node-scripts/src/pipeline3/scripts.js index 8a7063e..0003cf4 100644 --- a/node-scripts/src/pipeline3/scripts.js +++ b/node-scripts/src/pipeline3/scripts.js @@ -697,7 +697,7 @@ module.exports = { writeProperty(propertyName, value, filename) { var script = ""; - script += `if ! grep -R "^[#]*\s*${propertyName}.*" ${filename} > /dev/null; then\n`; + script += `if ! grep -w "${propertyName}" ${filename} > /dev/null; then\n`; script += `\techo "'${propertyName}' is not found in file '${filename}'. Appending..."\n`; script += `\techo "${propertyName}=${value}" >> ${filename}\n`; script += "else\n";