diff --git a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java index 5b63e656..c02e734f 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java +++ b/src/main/java/io/jenkins/plugins/jfrog/CliEnvConfigurator.java @@ -81,15 +81,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. + * @return A comma-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 commas 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..4bd6ec41 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/CreateNoProxyValueTest.java @@ -27,16 +27,19 @@ 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[]{",,,", ""}, 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"} ); }