When creating a new job from the REST API using an XML file:
The job is correctly created BUT the builds directory does not contains the legacyIds file. The same happens when using the create-job command with the Jenkins CLI, we see the same behavior.
When creating a job from the UI however, the legacyIds is correctly added.
The absence of the legacyIds file cause the RunIdMigrator to "migrate" that job on the next startup.
If many jobs are created using the REST API, this can slow down the next startup considerably. Some users that are automating the creating of items could be impacted.
Create the job first "from scratch" then update the XML file:
The "RunIdMigrator" is instantiated in Job and AbstractProject when the Item#onCreatedFromScratch is called. But this is not called when using the REST API to copy a job or to create an item from XML: