From c46dc4becbbfa9574277cb8232e45ba53c293238 Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Mon, 27 May 2024 05:13:58 +0200 Subject: [PATCH] [JENKINS-64356] fix legacyIds missing when creating jobs via REST API or CLI (#9303) * [JENKINS-64356] call onCreatedFromScratch after creating item via api or cli When creating jobs via the rest api or cli the call to onCreatedFromScratch was missing. This can lead to long startup times when many jobs are created this way. * remove unused import --- core/src/main/java/hudson/model/ItemGroupMixIn.java | 1 + test/src/test/java/jenkins/model/RunIdMigratorTest.java | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 2a6b264db9de..faa214dee621 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -290,6 +290,7 @@ public synchronized TopLevelItem createProjectFromXML(String name, InputStream x add(result); + result.onCreatedFromScratch(); ItemListener.fireOnCreated(result); Jenkins.get().rebuildDependencyGraphAsync(); diff --git a/test/src/test/java/jenkins/model/RunIdMigratorTest.java b/test/src/test/java/jenkins/model/RunIdMigratorTest.java index 4ade1afc84e1..cb7903435d80 100644 --- a/test/src/test/java/jenkins/model/RunIdMigratorTest.java +++ b/test/src/test/java/jenkins/model/RunIdMigratorTest.java @@ -39,7 +39,6 @@ import java.nio.charset.StandardCharsets; import org.htmlunit.HttpMethod; import org.htmlunit.WebRequest; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.Issue; @@ -58,7 +57,6 @@ public void legacyIdsPresent() throws Exception { assertTrue(legacyIds.exists()); } - @Ignore("TODO Item#onCreatedFromScratch is not called") @Issue("JENKINS-64356") @Test public void legacyIdsPresentViaRestApi() throws Exception { @@ -82,7 +80,6 @@ public void legacyIdsPresentViaRestApi() throws Exception { assertTrue(legacyIds.exists()); } - @Ignore("TODO Item#onCreatedFromScratch is not called") @Issue("JENKINS-64356") @Test public void legacyIdsPresentViaCli() {