From 87aba7863602c756e7fcba3a80d257ccd355277d Mon Sep 17 00:00:00 2001 From: nathana Date: Thu, 19 Sep 2024 16:11:55 +0300 Subject: [PATCH 01/11] Support pipe and new line in the 'No proxy host' --- .../plugins/jfrog/CliEnvConfigurator.java | 12 ++++- .../jfrog/CliEnvConfiguratorNoProxyTest.java | 47 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/test/java/io/jenkins/plugins/jfrog/CliEnvConfiguratorNoProxyTest.java diff --git a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java index 7cae8cd1..c57fccf1 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java +++ b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java @@ -5,6 +5,7 @@ import io.jenkins.plugins.jfrog.configuration.JenkinsProxyConfiguration; import org.apache.commons.lang3.StringUtils; + /** * Configures JFrog CLI environment variables for the job. * @@ -66,7 +67,7 @@ private static void setupProxy(EnvVars env) { env.put(HTTP_PROXY_ENV, proxyUrl); env.put(HTTPS_PROXY_ENV, proxyUrl); if (StringUtils.isNotBlank(proxyConfiguration.noProxy)) { - env.put(NO_PROXY, proxyConfiguration.noProxy); + env.put(NO_PROXY, noProxyExtractor(proxyConfiguration.noProxy)); } } @@ -79,4 +80,13 @@ private static void excludeProxyEnvFromPublishing(EnvVars env) { String jfrogCliEnvExclude = env.getOrDefault(JFROG_CLI_ENV_EXCLUDE, JFROG_CLI_DEFAULT_EXCLUSIONS); env.put(JFROG_CLI_ENV_EXCLUDE, String.join(";", jfrogCliEnvExclude, HTTP_PROXY_ENV, HTTPS_PROXY_ENV)); } + + static String noProxyExtractor(String noProxyList) { + // Trim leading and trailing spaces + String noProxyListTrim = noProxyList.trim(); + // Replace '|' with spaces and normalize whitespace + String noProxyListRemoveSpaceAndPipe = noProxyListTrim.replace("|", " ").replaceAll("\\s+", ";"); + // Replace multiple spaces with a single semicolon + return noProxyListRemoveSpaceAndPipe.replaceAll(";+", ";").replaceAll(";$", ""); + } } diff --git a/src/test/java/io/jenkins/plugins/jfrog/CliEnvConfiguratorNoProxyTest.java b/src/test/java/io/jenkins/plugins/jfrog/CliEnvConfiguratorNoProxyTest.java new file mode 100644 index 00000000..dfd28cdf --- /dev/null +++ b/src/test/java/io/jenkins/plugins/jfrog/CliEnvConfiguratorNoProxyTest.java @@ -0,0 +1,47 @@ +package io.jenkins.plugins.jfrog; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.Arrays; +import java.util.Collection; + +import static io.jenkins.plugins.jfrog.CliEnvConfigurator.noProxyExtractor; +import static org.junit.Assert.assertEquals; + +/** + * @author nathana + **/ +@RunWith(Parameterized.class) +public class CliEnvConfiguratorNoProxyTest { + private final String noProxyList; + private final String expectedResult; + + public CliEnvConfiguratorNoProxyTest(String noProxyList, String expectedResult) { + this.noProxyList = noProxyList; + this.expectedResult = expectedResult; + } + + @Parameterized.Parameters + public static Collection dataProvider() { + return Arrays.asList( + // Positive tests + new Object[]{"artifactory.jfrog.io", "artifactory.jfrog.io"}, + new Object[]{"artifactory.jfrog.io \n artifactory1.jfrog.io ", "artifactory.jfrog.io;artifactory1.jfrog.io"}, + new Object[]{" artifactory.jfrog.io \n \r artifactory1.jfrog.io;artifactory2.jfrog.io \n artifactory3.jfrog.io | artifactory4.jfrog.io \n artifactory5.jfrog.io ", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io;artifactory4.jfrog.io;artifactory5.jfrog.io"}, + new Object[]{"\r\n", ""}, + new Object[]{";;;", ""}, + new Object[]{"artifactory.jfrog.io;", "artifactory.jfrog.io"}, + new Object[]{"artifactory.jfrog.io;artifactory1.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io"}, + new Object[]{"artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io"}, + new Object[]{"artifactory.jfrog.io \nartifactory1.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io"}, + new Object[]{"artifactory.jfrog.io \nartifactory1.jfrog.io\nartifactory2.jfrog.io \n artifactory3.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io"} + ); + } + + @Test + public void testValidateCliVersion() { + assertEquals(expectedResult, noProxyExtractor(noProxyList)); + } +} From 0b02a0423708a851cb32792ba9ed56874d0d8875 Mon Sep 17 00:00:00 2001 From: Nathan770 Date: Thu, 19 Sep 2024 16:38:10 +0300 Subject: [PATCH 02/11] Support pipe and new line in the 'No proxy host' --- README.md | 2 +- .../java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java | 1 - ...figuratorNoProxyTest.java => NoProxyExtractorTest.java} | 7 +++---- 3 files changed, 4 insertions(+), 6 deletions(-) rename src/test/java/io/jenkins/plugins/jfrog/{CliEnvConfiguratorNoProxyTest.java => NoProxyExtractorTest.java} (91%) diff --git a/README.md b/README.md index daa99241..879586cd 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ If you're using a JFrog platform that's situated behind an HTTP/S proxy, you sho under `Manage Jenkins` > `Manage Plugins` > `Advanced`. To exclude the JFrog platform from going through a configured proxy, provide your JFrog platform's host details in -the `No Proxy Host` section. This should be a list of comma-separated hosts. +the `No Proxy Host` section. Notice that the JFrog CLI is typically downloaded from releases.jfrog.io. You may need to add that to your list as well. ## Jenkins Configuration as Code diff --git a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java index c57fccf1..df258e73 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java +++ b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java @@ -5,7 +5,6 @@ import io.jenkins.plugins.jfrog.configuration.JenkinsProxyConfiguration; import org.apache.commons.lang3.StringUtils; - /** * Configures JFrog CLI environment variables for the job. * diff --git a/src/test/java/io/jenkins/plugins/jfrog/CliEnvConfiguratorNoProxyTest.java b/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java similarity index 91% rename from src/test/java/io/jenkins/plugins/jfrog/CliEnvConfiguratorNoProxyTest.java rename to src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java index dfd28cdf..82c57576 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/CliEnvConfiguratorNoProxyTest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java @@ -14,11 +14,11 @@ * @author nathana **/ @RunWith(Parameterized.class) -public class CliEnvConfiguratorNoProxyTest { +public class NoProxyExtractorTest { private final String noProxyList; private final String expectedResult; - public CliEnvConfiguratorNoProxyTest(String noProxyList, String expectedResult) { + public NoProxyExtractorTest(String noProxyList, String expectedResult) { this.noProxyList = noProxyList; this.expectedResult = expectedResult; } @@ -26,7 +26,6 @@ public CliEnvConfiguratorNoProxyTest(String noProxyList, String expectedResult) @Parameterized.Parameters public static Collection dataProvider() { return Arrays.asList( - // Positive tests new Object[]{"artifactory.jfrog.io", "artifactory.jfrog.io"}, new Object[]{"artifactory.jfrog.io \n artifactory1.jfrog.io ", "artifactory.jfrog.io;artifactory1.jfrog.io"}, new Object[]{" artifactory.jfrog.io \n \r artifactory1.jfrog.io;artifactory2.jfrog.io \n artifactory3.jfrog.io | artifactory4.jfrog.io \n artifactory5.jfrog.io ", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io;artifactory4.jfrog.io;artifactory5.jfrog.io"}, @@ -41,7 +40,7 @@ public static Collection dataProvider() { } @Test - public void testValidateCliVersion() { + public void testNoProxyExtractor() { assertEquals(expectedResult, noProxyExtractor(noProxyList)); } } From 98dc357b42941cf584e4199a461dae93d38cf594 Mon Sep 17 00:00:00 2001 From: Nathan770 Date: Thu, 19 Sep 2024 16:49:05 +0300 Subject: [PATCH 03/11] Support pipe and new line in the 'No proxy host' --- .../java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java index df258e73..e585ab10 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java +++ b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java @@ -81,11 +81,9 @@ private static void excludeProxyEnvFromPublishing(EnvVars env) { } static String noProxyExtractor(String noProxyList) { - // Trim leading and trailing spaces - String noProxyListTrim = noProxyList.trim(); - // Replace '|' with spaces and normalize whitespace - String noProxyListRemoveSpaceAndPipe = noProxyListTrim.replace("|", " ").replaceAll("\\s+", ";"); - // Replace multiple spaces with a single semicolon + // Trim leading and trailing spaces, Replace '|' with spaces and normalize whitespace + String noProxyListRemoveSpaceAndPipe = noProxyList.trim().replaceAll("[\\s|]+", ";"); + // Replace multiple semicolon with a single semicolon, and remove the last one if present return noProxyListRemoveSpaceAndPipe.replaceAll(";+", ";").replaceAll(";$", ""); } } From 411956bc6fa45f86c2d47c189569b6385da3ca01 Mon Sep 17 00:00:00 2001 From: Nathan770 Date: Thu, 19 Sep 2024 17:38:10 +0300 Subject: [PATCH 04/11] Support pipe and new line in the 'No proxy host' --- .../jenkins/plugins/jfrog/CliEnvConfigurator.java | 15 ++++++++++----- .../plugins/jfrog/NoProxyExtractorTest.java | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java index e585ab10..ecf9d6c3 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java +++ b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java @@ -66,7 +66,7 @@ private static void setupProxy(EnvVars env) { env.put(HTTP_PROXY_ENV, proxyUrl); env.put(HTTPS_PROXY_ENV, proxyUrl); if (StringUtils.isNotBlank(proxyConfiguration.noProxy)) { - env.put(NO_PROXY, noProxyExtractor(proxyConfiguration.noProxy)); + env.put(NO_PROXY, createNoProxyValue(proxyConfiguration.noProxy)); } } @@ -79,11 +79,16 @@ private static void excludeProxyEnvFromPublishing(EnvVars env) { String jfrogCliEnvExclude = env.getOrDefault(JFROG_CLI_ENV_EXCLUDE, JFROG_CLI_DEFAULT_EXCLUSIONS); env.put(JFROG_CLI_ENV_EXCLUDE, String.join(";", jfrogCliEnvExclude, HTTP_PROXY_ENV, HTTPS_PROXY_ENV)); } - - static String noProxyExtractor(String noProxyList) { + /** + * Converts a list of No Proxy Hosts received by Jenkins into a semicolon-separated string format expected by JFrog CLI. + * + * @param noProxy - A string representing the list of No Proxy Hosts. + * @return A semicolon-separated string of No Proxy Hosts. + */ + static String createNoProxyValue(String noProxy) { // Trim leading and trailing spaces, Replace '|' with spaces and normalize whitespace - String noProxyListRemoveSpaceAndPipe = noProxyList.trim().replaceAll("[\\s|]+", ";"); + String noProxyListRemoveSpaceAndPipe = noProxy.trim().replaceAll("[\\s|]+", ";"); // Replace multiple semicolon with a single semicolon, and remove the last one if present - return noProxyListRemoveSpaceAndPipe.replaceAll(";+", ";").replaceAll(";$", ""); + return noProxyListRemoveSpaceAndPipe.replaceAll(";+", ";").replaceAll("^;|;$", ""); } } diff --git a/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java b/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java index 82c57576..3ad3779d 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java @@ -35,7 +35,8 @@ public static Collection dataProvider() { new Object[]{"artifactory.jfrog.io;artifactory1.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io"}, new Object[]{"artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io"}, new Object[]{"artifactory.jfrog.io \nartifactory1.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io"}, - new Object[]{"artifactory.jfrog.io \nartifactory1.jfrog.io\nartifactory2.jfrog.io \n artifactory3.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io"} + new Object[]{"artifactory.jfrog.io \nartifactory1.jfrog.io\nartifactory2.jfrog.io \n artifactory3.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io"}, + new Object[]{";artifactory.jfrog.io;", "artifactory.jfrog.io"} ); } From b6e3157023ee2f034f04c06cffa457e1a08c092e Mon Sep 17 00:00:00 2001 From: Nathan770 Date: Thu, 19 Sep 2024 17:40:31 +0300 Subject: [PATCH 05/11] Support pipe and new line in the 'No proxy host' --- .../java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java | 1 + .../java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java index ecf9d6c3..5b63e656 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java +++ b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java @@ -79,6 +79,7 @@ private static void excludeProxyEnvFromPublishing(EnvVars env) { String jfrogCliEnvExclude = env.getOrDefault(JFROG_CLI_ENV_EXCLUDE, JFROG_CLI_DEFAULT_EXCLUSIONS); env.put(JFROG_CLI_ENV_EXCLUDE, String.join(";", jfrogCliEnvExclude, HTTP_PROXY_ENV, HTTPS_PROXY_ENV)); } + /** * Converts a list of No Proxy Hosts received by Jenkins into a semicolon-separated string format expected by JFrog CLI. * diff --git a/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java b/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java index 3ad3779d..4110534c 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java @@ -7,7 +7,7 @@ import java.util.Arrays; import java.util.Collection; -import static io.jenkins.plugins.jfrog.CliEnvConfigurator.noProxyExtractor; +import static io.jenkins.plugins.jfrog.CliEnvConfigurator.createNoProxyValue; import static org.junit.Assert.assertEquals; /** @@ -42,6 +42,6 @@ public static Collection dataProvider() { @Test public void testNoProxyExtractor() { - assertEquals(expectedResult, noProxyExtractor(noProxyList)); + assertEquals(expectedResult, createNoProxyValue(noProxyList)); } } From 2172a2a74239be3077515c95ecb48965b2fcca52 Mon Sep 17 00:00:00 2001 From: Nathan770 Date: Thu, 19 Sep 2024 19:34:41 +0300 Subject: [PATCH 06/11] Support pipe and new line in the 'No proxy host' --- ...yExtractorTest.java => CreateNoProxyValueTest.java} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename src/test/java/io/jenkins/plugins/jfrog/{NoProxyExtractorTest.java => CreateNoProxyValueTest.java} (89%) diff --git a/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java b/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java similarity index 89% rename from src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java rename to src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java index 4110534c..b6f096d6 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/NoProxyExtractorTest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java @@ -14,12 +14,12 @@ * @author nathana **/ @RunWith(Parameterized.class) -public class NoProxyExtractorTest { - private final String noProxyList; +public class CreateNoProxyValueTest { + private final String noProxy; private final String expectedResult; - public NoProxyExtractorTest(String noProxyList, String expectedResult) { - this.noProxyList = noProxyList; + public CreateNoProxyValueTest(String noProxy, String expectedResult) { + this.noProxy = noProxy; this.expectedResult = expectedResult; } @@ -42,6 +42,6 @@ public static Collection dataProvider() { @Test public void testNoProxyExtractor() { - assertEquals(expectedResult, createNoProxyValue(noProxyList)); + assertEquals(expectedResult, createNoProxyValue(noProxy)); } } From 990ff03de1e2c49b93f91bd1946dff28c13139ff Mon Sep 17 00:00:00 2001 From: Nathan770 Date: Mon, 23 Sep 2024 13:45:08 +0300 Subject: [PATCH 07/11] Support pipe and new line in the 'No proxy host' --- .../java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java b/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java index b6f096d6..22c0ba2a 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java @@ -41,7 +41,7 @@ public static Collection dataProvider() { } @Test - public void testNoProxyExtractor() { + public void createNoProxyValueTest() { assertEquals(expectedResult, createNoProxyValue(noProxy)); } } From c46b9b37ceaf78b58fa23b45dc8675f778e9f46c Mon Sep 17 00:00:00 2001 From: Nathan770 Date: Wed, 25 Sep 2024 12:38:11 +0300 Subject: [PATCH 08/11] change the separators from semicolons to commas --- .../plugins/jfrog/CliEnvConfigurator.java | 13 +++++++------ .../plugins/jfrog/CreateNoProxyValueTest.java | 16 +++++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java index 5b63e656..7723c0c9 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java +++ b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java @@ -66,7 +66,8 @@ private static void setupProxy(EnvVars env) { env.put(HTTP_PROXY_ENV, proxyUrl); env.put(HTTPS_PROXY_ENV, proxyUrl); if (StringUtils.isNotBlank(proxyConfiguration.noProxy)) { - env.put(NO_PROXY, createNoProxyValue(proxyConfiguration.noProxy)); + String test = createNoProxyValue(proxyConfiguration.noProxy); + env.put(NO_PROXY, test); } } @@ -81,15 +82,15 @@ private static void excludeProxyEnvFromPublishing(EnvVars env) { } /** - * Converts a list of No Proxy Hosts received by Jenkins into a semicolon-separated string format expected by JFrog CLI. + * Converts a list of No Proxy Hosts received by Jenkins into a comma-separated string format expected by JFrog CLI. * * @param noProxy - A string representing the list of No Proxy Hosts. * @return A semicolon-separated string of No Proxy Hosts. */ static String createNoProxyValue(String noProxy) { - // Trim leading and trailing spaces, Replace '|' with spaces and normalize whitespace - String noProxyListRemoveSpaceAndPipe = noProxy.trim().replaceAll("[\\s|]+", ";"); - // Replace multiple semicolon with a single semicolon, and remove the last one if present - return noProxyListRemoveSpaceAndPipe.replaceAll(";+", ";").replaceAll("^;|;$", ""); + // Trim leading and trailing spaces, Replace '|' and ';' with spaces and normalize whitespace + String noProxyListRemoveSpaceAndPipe = noProxy.trim().replaceAll("[\\s|;]+", ","); + // Replace multiple comma with a single comma, and remove the last one if present + return noProxyListRemoveSpaceAndPipe.replaceAll(",+", ",").replaceAll("^,|,$", ""); } } diff --git a/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java b/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java index 22c0ba2a..067c8508 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java @@ -27,16 +27,18 @@ public CreateNoProxyValueTest(String noProxy, String expectedResult) { public static Collection dataProvider() { return Arrays.asList( new Object[]{"artifactory.jfrog.io", "artifactory.jfrog.io"}, - new Object[]{"artifactory.jfrog.io \n artifactory1.jfrog.io ", "artifactory.jfrog.io;artifactory1.jfrog.io"}, - new Object[]{" artifactory.jfrog.io \n \r artifactory1.jfrog.io;artifactory2.jfrog.io \n artifactory3.jfrog.io | artifactory4.jfrog.io \n artifactory5.jfrog.io ", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io;artifactory4.jfrog.io;artifactory5.jfrog.io"}, + new Object[]{"artifactory.jfrog.io \n artifactory1.jfrog.io ", "artifactory.jfrog.io,artifactory1.jfrog.io"}, + new Object[]{" artifactory.jfrog.io \n \r artifactory1.jfrog.io;artifactory2.jfrog.io \n artifactory3.jfrog.io | artifactory4.jfrog.io \n artifactory5.jfrog.io ", "artifactory.jfrog.io,artifactory1.jfrog.io,artifactory2.jfrog.io,artifactory3.jfrog.io,artifactory4.jfrog.io,artifactory5.jfrog.io"}, new Object[]{"\r\n", ""}, new Object[]{";;;", ""}, new Object[]{"artifactory.jfrog.io;", "artifactory.jfrog.io"}, - new Object[]{"artifactory.jfrog.io;artifactory1.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io"}, - new Object[]{"artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io"}, - new Object[]{"artifactory.jfrog.io \nartifactory1.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io"}, - new Object[]{"artifactory.jfrog.io \nartifactory1.jfrog.io\nartifactory2.jfrog.io \n artifactory3.jfrog.io", "artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io"}, - new Object[]{";artifactory.jfrog.io;", "artifactory.jfrog.io"} + new Object[]{"artifactory.jfrog.io,artifactory1.jfrog.io", "artifactory.jfrog.io,artifactory1.jfrog.io"}, + new Object[]{"artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io", "artifactory.jfrog.io,artifactory1.jfrog.io,artifactory2.jfrog.io,artifactory3.jfrog.io"}, + new Object[]{"artifactory.jfrog.io|artifactory1.jfrog.io|artifactory2.jfrog.io|artifactory3.jfrog.io", "artifactory.jfrog.io,artifactory1.jfrog.io,artifactory2.jfrog.io,artifactory3.jfrog.io"}, + new Object[]{"artifactory.jfrog.io\nartifactory1.jfrog.io", "artifactory.jfrog.io,artifactory1.jfrog.io"}, + new Object[]{"artifactory.jfrog.io \nartifactory1.jfrog.io\nartifactory2.jfrog.io \n artifactory3.jfrog.io", "artifactory.jfrog.io,artifactory1.jfrog.io,artifactory2.jfrog.io,artifactory3.jfrog.io"}, + new Object[]{";artifactory.jfrog.io;", "artifactory.jfrog.io"}, + new Object[]{",artifactory.jfrog.io,", "artifactory.jfrog.io"} ); } From 217fb83b79c22e69b5e7dbd6af60153bac0ca923 Mon Sep 17 00:00:00 2001 From: Nathan Amiel <59163863+Nathan770@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:57:40 +0300 Subject: [PATCH 09/11] Update src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java Co-authored-by: Yahav Itschak --- src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java index c60b6a7f..55cd683e 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java +++ b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java @@ -84,7 +84,7 @@ private static void excludeProxyEnvFromPublishing(EnvVars env) { * Converts a list of No Proxy Hosts received by Jenkins into a comma-separated string format expected by JFrog CLI. * * @param noProxy - A string representing the list of No Proxy Hosts. - * @return A semicolon-separated string of No Proxy Hosts. + * @return A comma-separated string of No Proxy Hosts. */ static String createNoProxyValue(String noProxy) { // Trim leading and trailing spaces, Replace '|' and ';' with spaces and normalize whitespace From a8a30f1fbeb6c2ea00abded9ce86b4b85e6fda92 Mon Sep 17 00:00:00 2001 From: Nathan Amiel <59163863+Nathan770@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:57:46 +0300 Subject: [PATCH 10/11] Update src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java Co-authored-by: Yahav Itschak --- src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java index 55cd683e..c02e734f 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java +++ b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java @@ -89,7 +89,7 @@ private static void excludeProxyEnvFromPublishing(EnvVars env) { static String createNoProxyValue(String noProxy) { // Trim leading and trailing spaces, Replace '|' and ';' with spaces and normalize whitespace String noProxyListRemoveSpaceAndPipe = noProxy.trim().replaceAll("[\\s|;]+", ","); - // Replace multiple comma with a single comma, and remove the last one if present + // Replace multiple commas with a single comma, and remove the last one if present return noProxyListRemoveSpaceAndPipe.replaceAll(",+", ",").replaceAll("^,|,$", ""); } } From 55687d6fa8bf1a3cbaba2c952d88b09c9abc9809 Mon Sep 17 00:00:00 2001 From: Nathan Amiel <59163863+Nathan770@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:03:14 +0300 Subject: [PATCH 11/11] Update CreateNoProxyValueTest.java added test --- .../java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java b/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java index 067c8508..4bd6ec41 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java @@ -31,6 +31,7 @@ public static Collection dataProvider() { new Object[]{" artifactory.jfrog.io \n \r artifactory1.jfrog.io;artifactory2.jfrog.io \n artifactory3.jfrog.io | artifactory4.jfrog.io \n artifactory5.jfrog.io ", "artifactory.jfrog.io,artifactory1.jfrog.io,artifactory2.jfrog.io,artifactory3.jfrog.io,artifactory4.jfrog.io,artifactory5.jfrog.io"}, new Object[]{"\r\n", ""}, new Object[]{";;;", ""}, + new Object[]{",,,", ""}, new Object[]{"artifactory.jfrog.io;", "artifactory.jfrog.io"}, new Object[]{"artifactory.jfrog.io,artifactory1.jfrog.io", "artifactory.jfrog.io,artifactory1.jfrog.io"}, new Object[]{"artifactory.jfrog.io;artifactory1.jfrog.io;artifactory2.jfrog.io;artifactory3.jfrog.io", "artifactory.jfrog.io,artifactory1.jfrog.io,artifactory2.jfrog.io,artifactory3.jfrog.io"},