From adec0daf7629378ccb496468a2b046cb731c650f Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Thu, 23 May 2024 22:50:24 +0200 Subject: [PATCH] [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. --- core/src/main/java/hudson/model/ItemGroupMixIn.java | 1 + test/src/test/java/jenkins/model/RunIdMigratorTest.java | 2 -- 2 files changed, 1 insertion(+), 2 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..494d0a94b208 100644 --- a/test/src/test/java/jenkins/model/RunIdMigratorTest.java +++ b/test/src/test/java/jenkins/model/RunIdMigratorTest.java @@ -58,7 +58,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 +81,6 @@ public void legacyIdsPresentViaRestApi() throws Exception { assertTrue(legacyIds.exists()); } - @Ignore("TODO Item#onCreatedFromScratch is not called") @Issue("JENKINS-64356") @Test public void legacyIdsPresentViaCli() {