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 legacybuilds
directories to the current format. There would be one instance associated with eachJob
, to retain ID → build# mapping. TheJob.getBuildDir()
is passed to every method call (rather than being cached) in case it is moved.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RunIdMigrator.UnmigrationInstruction
Expose unmigration instruction to the user.
-
Constructor Summary
Constructors Constructor Description RunIdMigrator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
created(File dir)
Called when a job is first created.void
delete(File dir, String id)
Delete the record of a build.int
findNumber(String id)
Look up a historical run by ID.static void
main(String... args)
Reverses the migration, in case you want to revert to the older format.boolean
migrate(File dir, File jenkinsHome)
Perform one-time migration if this has not been done already.
-
-
-
Method Detail
-
created
public void created(File dir)
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
public boolean migrate(File dir, @CheckForNull File jenkinsHome)
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
public int findNumber(@NonNull String id)
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
public void delete(File dir, String id)
Delete the record of a build.- Parameters:
dir
- as inJob.getBuildDir()
id
- aRun.getId()
-
-