From 813e514c072e6d7df6a3eaccb5c6aa0b3981e7e3 Mon Sep 17 00:00:00 2001 From: guruprasad Date: Tue, 25 Mar 2025 13:09:39 +0530 Subject: [PATCH] Remove the support for legacyIds based directory mapping
Background Jenkins previously changed the naming convention for build directories from a date-time-based format to a build number-based format. To facilitate this transition, an automated migrator, `RunIdMigrator`, was introduced to rename existing build folders accordingly. [jenkinsci/jenkins/pull/10456](https://github.com/jenkinsci/jenkins/pull/10456) removes `RunIdMigrator` from Jenkins core, meaning direct upgrades from Jenkins 1.596 (or earlier) to the latest version will no longer be supported. Users must first upgrade to an intermediate version before upgrading to the latest release.
**Why is it no longer necessary to check legacyIds mapping in this plugin?** The method `recalculateBasePath` previously translated a base path like: `/path/to/jhome/jobs/my-job/builds/2014-12-01-00-01-01/tcreports` to `/path/to/jhome/jobs/my-job/builds/10/tcreports`; where `2014-12-01-00-01-01` mapped to build number `10` using the `legacyIds` file. However, since Jenkins `1.597` (released on 2015-01-19), new jobs no longer populate the `legacyIds` file, it simply empty. This means for any job created in the last 10+ years, the method has been effectively returning `basePath` unchanged. Given that virtually all jobs and controllers in use today fall into this category, the legacy lookup is no longer needed, and this removal simplifies the code while maintaining expected behavior. --- .../plugins/testcomplete/Constants.java | 1 - .../testcomplete/TcDynamicReportAction.java | 44 +------------------ 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/src/main/java/com/smartbear/jenkins/plugins/testcomplete/Constants.java b/src/main/java/com/smartbear/jenkins/plugins/testcomplete/Constants.java index 7fe5fa9..597e739 100644 --- a/src/main/java/com/smartbear/jenkins/plugins/testcomplete/Constants.java +++ b/src/main/java/com/smartbear/jenkins/plugins/testcomplete/Constants.java @@ -42,7 +42,6 @@ public class Constants { public static final String MHT_FILE_EXTENSION = ".mht"; public static final String ERROR_FILE_EXTENSION = ".txt"; public static final String ANY_CONSTANT = "any"; - public static final String LEGACY_IDS_FILE_NAME = "legacyIds"; public static final String SERVICE_ARG = "//LogonAndExecute"; public static final String SERVICE_ARG_DOMAIN = "//lDomain:"; diff --git a/src/main/java/com/smartbear/jenkins/plugins/testcomplete/TcDynamicReportAction.java b/src/main/java/com/smartbear/jenkins/plugins/testcomplete/TcDynamicReportAction.java index d340694..77550e1 100644 --- a/src/main/java/com/smartbear/jenkins/plugins/testcomplete/TcDynamicReportAction.java +++ b/src/main/java/com/smartbear/jenkins/plugins/testcomplete/TcDynamicReportAction.java @@ -34,9 +34,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import static com.smartbear.jenkins.plugins.testcomplete.Constants.LEGACY_IDS_FILE_NAME; -import static com.smartbear.jenkins.plugins.testcomplete.Constants.REPORTS_DIRECTORY_NAME; - /** * @author Igor Filin */ @@ -99,7 +96,7 @@ public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOExceptio if (basePathCache != null) { basePath = basePathCache; } else { - basePath = recalculateBasePath(baseReportsPath); + basePath = baseReportsPath; basePathCache = basePath; } @@ -171,43 +168,4 @@ private ZipEntry searchEntry(ZipFile archive, String entryName) { } return targetEntry; } - - // https://wiki.jenkins.io/display/JENKINS/JENKINS-24380+Migration - private String recalculateBasePath(String basePath) { - File path = new File(basePath); - - if (!path.exists()) { - path = path.getParentFile(); - - String oldDirectoryName = path.getName(); - - try { - try (BufferedReader br = new BufferedReader( - new InputStreamReader( - new FileInputStream( - new File(path.getParentFile(), LEGACY_IDS_FILE_NAME) - ), "UTF-8" - ) - ) - ) { - String line; - while ((line = br.readLine()) != null) { - String parts[] = line.split("( )"); - if ((parts.length == 2) && (parts[0].equals(oldDirectoryName))) { - File newPath = new File(path.getParentFile(), parts[1] + File.separatorChar + REPORTS_DIRECTORY_NAME); - if (newPath.exists()) { - return newPath.getAbsolutePath(); - } - break; - } - } - } - } catch (IOException e) { - // Do nothing - } - } - - return basePath; - } - } \ No newline at end of file