Package jenkins.model
Class RunIdMigrator
java.lang.Object
jenkins.model.RunIdMigrator
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public final class RunIdMigrator
extends Object
Converts legacy
builds
directories to the current format.
There would be one instance associated with each Job
, to retain ID → build# mapping.
The Job.getBuildDir()
is passed to every method call (rather than being cached) in case it is moved.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Called when a job is first created.void
Delete the record of a build.int
findNumber
(String id) Look up a historical run by ID.boolean
Perform one-time migration if this has not been done already.
-
Constructor Details
-
RunIdMigrator
public RunIdMigrator()
-
-
Method Details
-
created
Called when a job is first created. Just saves an empty marker indicating that this job needs no migration.- Parameters:
dir
- as inJob.getBuildDir()
-
migrate
Perform one-time migration if this has not been done already. Where previously there would be a2014-01-02_03-04-05/build.xml
specifying<number>99</number>
plus a symlink99 → 2014-01-02_03-04-05
, after migration there will be just99/build.xml
specifying<id>2014-01-02_03-04-05</id>
and<timestamp>…</timestamp>
according to local time zone at time of migration. Newly created builds are untouched. Does not throwIOException
since we make a best effort to migrate but do not consider it fatal to job loading if we cannot.- Parameters:
dir
- as inJob.getBuildDir()
jenkinsHome
- root directory of Jenkins (for logging only)- Returns:
- true if migration was performed
-
findNumber
Look up a historical run by ID.- Parameters:
id
- a nonnumeric ID which may be a validRun.getId()
- Returns:
- the corresponding
Run.number
, or 0 if unknown
-
delete
Delete the record of a build.- Parameters:
dir
- as inJob.getBuildDir()
id
- aRun.getId()
-