From b6f2b4bbc37cfb08e02a85af8aaaa2bd2bde7ed4 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 27 Jan 2022 20:34:27 +0000 Subject: [PATCH] Handle new JEP-229 versioning --- .../org/jenkins/tools/test/PluginCompatTester.java | 2 +- .../jenkins/tools/test/PluginCompatTesterTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java index edd0dfe25..81775dbda 100644 --- a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java +++ b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java @@ -124,7 +124,7 @@ public class PluginCompatTester { private static final String DEFAULT_SOURCE_ID = "default"; /** First version with new parent POM. */ - public static final String JENKINS_CORE_FILE_REGEX = "WEB-INF/lib/jenkins-core-([0-9.]+(?:-[0-9a-f.]+)*(?:-(?i)([a-z]+)(-)?([0-9a-f.]+)?)?(?:-(?i)([a-z]+)(-)?([0-9a-f.]+)?)?(?:-SNAPSHOT)?)[.]jar"; + public static final String JENKINS_CORE_FILE_REGEX = "WEB-INF/lib/jenkins-core-([0-9.]+(?:-[0-9a-f.]+)*(?:-(?i)([a-z]+)(-)?([0-9a-f.]+)?)?(?:-(?i)([a-z]+)(-)?([0-9a-f_.]+)?)?(?:-SNAPSHOT)?)[.]jar"; private PluginCompatTesterConfig config; private final ExternalMavenRunner runner; diff --git a/plugins-compat-tester/src/test/java/org/jenkins/tools/test/PluginCompatTesterTest.java b/plugins-compat-tester/src/test/java/org/jenkins/tools/test/PluginCompatTesterTest.java index d85626d82..0dcbaffdc 100644 --- a/plugins-compat-tester/src/test/java/org/jenkins/tools/test/PluginCompatTesterTest.java +++ b/plugins-compat-tester/src/test/java/org/jenkins/tools/test/PluginCompatTesterTest.java @@ -25,6 +25,8 @@ */ package org.jenkins.tools.test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -409,6 +411,15 @@ public void testCustomWarPackagerVersions() { assertTrue("No matches", m.matches()); } + @Test + @Issue("340") + public void testJEP229WithUnderscore() { + String fileName = "WEB-INF/lib/jenkins-core-2.329-rc31964.3b_29e9d46_038_.jar"; + Matcher m = Pattern.compile(PluginCompatTester.JENKINS_CORE_FILE_REGEX).matcher(fileName); + assertThat("No matches", m.matches(), is(true)); + assertThat("Invalid group", m.group(1), is("2.329-rc31964.3b_29e9d46_038_")); + } + private static File getSettingsFile() throws IOException { // Check whether we run in ci.jenkins.io with Azure settings File ciJenkinsIOSettings = new File(new File("settings-azure.xml").getAbsolutePath()