@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public final class RunIdMigrator extends Object
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.Modifier and Type | Class and Description |
---|---|
static class |
RunIdMigrator.UnmigrationInstruction
Expose unmigration instruction to the user.
|
Constructor and Description |
---|
RunIdMigrator() |
Modifier and Type | Method and 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.
|
public void created(File dir)
dir
- as in Job.getBuildDir()
public boolean migrate(File dir, @CheckForNull File jenkinsHome)
2014-01-02_03-04-05/build.xml
specifying <number>99</number>
plus a symlink 99 → 2014-01-02_03-04-05
,
after migration there will be just 99/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 throw IOException
since we make a best effort to migrate but do not consider it fatal to job loading if we cannot.dir
- as in Job.getBuildDir()
jenkinsHome
- root directory of Jenkins (for logging only)public int findNumber(@NonNull String id)
id
- a nonnumeric ID which may be a valid Run.getId()
Run.number
, or 0 if unknownpublic void delete(File dir, String id)
dir
- as in Job.getBuildDir()
id
- a Run.getId()
Copyright © 2004–2021. All rights reserved.