Skip to content

Commit

Permalink
[JENKINS-64356] fix legacyIds missing when creating jobs via REST API…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
mawinter69 authored May 27, 2024
1 parent 8c5026a commit c46dc4b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/hudson/model/ItemGroupMixIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public synchronized TopLevelItem createProjectFromXML(String name, InputStream x

add(result);

result.onCreatedFromScratch();
ItemListener.fireOnCreated(result);
Jenkins.get().rebuildDependencyGraphAsync();

Expand Down
3 changes: 0 additions & 3 deletions test/src/test/java/jenkins/model/RunIdMigratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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() {
Expand Down

0 comments on commit c46dc4b

Please sign in to comment.