Class Fingerprint
- java.lang.Object
-
- hudson.model.Fingerprint
-
- All Implemented Interfaces:
ModelObject,Saveable
@ExportedBean public class Fingerprint extends Object implements ModelObject, Saveable
A file being tracked by Jenkins.Lifecycle is managed by
FingerprintMap.- Author:
- Kohsuke Kawaguchi
- See Also:
FingerprintMap
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFingerprint.BuildPtrPointer to aBuild.static classFingerprint.ProjectRenameListenerstatic classFingerprint.RangeRange of build numbers [start,end).static classFingerprint.RangeItemstatic classFingerprint.RangeSetSet ofFingerprint.Ranges.
-
Constructor Summary
Constructors Constructor Description Fingerprint(Run build, String fileName, byte[] md5sum)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description List<Fingerprint.RangeItem>_getUsages()voidadd(AbstractBuild b)Deprecated.voidadd(String jobFullName, int n)Records that a build of a job has used this file.voidaddFor(Run b)Adds a usage reference to the build.static voiddelete(String id)Deletes theFingerprintin the configured storage with the given unique id.List<Action>getActions()Returns the actions contributed fromgetFacets()ApigetApi()StringgetDisplayName()<T extends FingerprintFacet>
TgetFacet(Class<T> type)Finds a facet of the specific type (including subtypes.)FingerprintFacetgetFacetBlockingDeletion()Returns a facet that blocks the deletion of the fingerprint.Collection<FingerprintFacet>getFacets()Gets the associatedFingerprintFacets.StringgetFileName()The file name (like "foo.jar" without path).StringgetHashString()Gets the MD5 hash string.List<String>getJobs()Gets the sorted list of job names where this jar is used.Fingerprint.BuildPtrgetOriginal()The first build in which this file showed up, if the file looked like it's created there.PersistedList<FingerprintFacet>getPersistedFacets()Returns the persisted facets.Fingerprint.RangeSetgetRangeSet(Job job)Fingerprint.RangeSetgetRangeSet(String jobFullName)Gets the build range set for the given job name.Collection<FingerprintFacet>getSortedFacets()SortsFingerprintFacets by their timestamps.DategetTimestamp()Gets the timestamp when this record is created.StringgetTimestampString()Gets the string that says how long since this build has scheduled.Hashtable<String,Fingerprint.RangeSet>getUsages()static XStream2getXStream()Provides the XStream instance this class is using for serialization.booleanisAlive()Returns true if any of the builds recorded in this fingerprint is still retained.static Fingerprintload(String id)Loads aFingerprintfrom the Storage with the given unique id.protected ObjectreadResolve()voidrename(String oldName, String newName)Update references to a renamed job in the fingerprintvoidsave()Save the Fingerprint in the Fingerprint StorageStringtoString()booleantrim()Trim off references to non-existent builds and jobs, thereby making the fingerprint smaller.
-
-
-
Constructor Detail
-
Fingerprint
public Fingerprint(@CheckForNull Run build, @NonNull String fileName, @NonNull byte[] md5sum) throws IOException- Throws:
IOException
-
-
Method Detail
-
getOriginal
@Exported @CheckForNull public Fingerprint.BuildPtr getOriginal()
The first build in which this file showed up, if the file looked like it's created there.This is considered as the "source" of this file, or the owner, in the sense that this project "owns" this file.
- Returns:
- null if the file is apparently created outside Hudson or if the current user has no permission to discover the job.
-
getDisplayName
@NonNull public String getDisplayName()
- Specified by:
getDisplayNamein interfaceModelObject
-
getFileName
@Exported @NonNull public String getFileName()
The file name (like "foo.jar" without path).
-
getHashString
@Exported(name="hash") @NonNull public String getHashString()
Gets the MD5 hash string.
-
getTimestamp
@Exported @NonNull public Date getTimestamp()
Gets the timestamp when this record is created.
-
getTimestampString
@NonNull public String getTimestampString()
Gets the string that says how long since this build has scheduled.- Returns:
- string like "3 minutes" "1 day" etc.
-
getRangeSet
@NonNull public Fingerprint.RangeSet getRangeSet(String jobFullName)
Gets the build range set for the given job name.These builds of this job has used this file.
- Returns:
- may be empty but not null.
-
getRangeSet
public Fingerprint.RangeSet getRangeSet(Job job)
-
getJobs
@NonNull public List<String> getJobs()
Gets the sorted list of job names where this jar is used.
-
getUsages
@CheckForNull public Hashtable<String,Fingerprint.RangeSet> getUsages()
-
_getUsages
@Exported(name="usage") @NonNull public List<Fingerprint.RangeItem> _getUsages()
-
add
@Deprecated public void add(@NonNull AbstractBuild b) throws IOException
Deprecated.- Throws:
IOException
-
addFor
public void addFor(@NonNull Run b) throws IOExceptionAdds a usage reference to the build.- Parameters:
b-Runto be referenced inusages- Throws:
IOException- Since:
- 1.577
-
add
public void add(@NonNull String jobFullName, int n) throws IOExceptionRecords that a build of a job has used this file.- Throws:
IOException
-
readResolve
protected Object readResolve()
-
isAlive
public boolean isAlive()
Returns true if any of the builds recorded in this fingerprint is still retained.This is used to find out old fingerprint records that can be removed without losing too much information.
-
trim
public boolean trim() throws IOExceptionTrim off references to non-existent builds and jobs, thereby making the fingerprint smaller.- Returns:
- true if this record was modified.
- Throws:
IOException- Save failure
-
getFacets
@NonNull public Collection<FingerprintFacet> getFacets()
Gets the associatedFingerprintFacets.This method always return a non-empty collection, which is a synthetic collection. It contains persisted
FingerprintFacets (those that are added explicitly, likefingerprint.getFacets().add(x)), as well those that are transient.Mutation to this collection will manipulate persisted set of
FingerprintFacets, and therefore regardless of what you do, this collection will always contain a set ofFingerprintFacets that are added byTransientFingerprintFacetFactorys.- Since:
- 1.421
-
getPersistedFacets
@NonNull public final PersistedList<FingerprintFacet> getPersistedFacets()
Returns the persisted facets.- Since:
- 2.242
-
getSortedFacets
@NonNull public Collection<FingerprintFacet> getSortedFacets()
SortsFingerprintFacets by their timestamps.- Returns:
- Sorted list of
FingerprintFacets
-
getFacet
@CheckForNull public <T extends FingerprintFacet> T getFacet(Class<T> type)
Finds a facet of the specific type (including subtypes.)- Type Parameters:
T- Class of theFingerprintFacet- Returns:
- First matching facet of the specified class
- Since:
- 1.556
-
getActions
@NonNull public List<Action> getActions()
Returns the actions contributed fromgetFacets()
-
save
public void save() throws IOExceptionSave the Fingerprint in the Fingerprint Storage- Specified by:
savein interfaceSaveable- Throws:
IOException- Save error
-
getFacetBlockingDeletion
@CheckForNull public FingerprintFacet getFacetBlockingDeletion()
Returns a facet that blocks the deletion of the fingerprint. Returns null if no such facet.- Since:
- 2.223
-
rename
public void rename(String oldName, String newName) throws IOException
Update references to a renamed job in the fingerprint- Throws:
IOException
-
getApi
public Api getApi()
-
load
@CheckForNull public static Fingerprint load(@NonNull String id) throws IOException
Loads aFingerprintfrom the Storage with the given unique id.- Returns:
- Loaded
Fingerprint.nullif the config file does not exist or malformed. In case an external storage is configured on top of a file system based storage: 1. External storage is polled to retrieve the fingerprint 2. If not found, then the local storage is polled to retrieve the fingerprint - Throws:
IOException
-
delete
public static void delete(@NonNull String id) throws IOExceptionDeletes theFingerprintin the configured storage with the given unique id.- Throws:
IOException- Since:
- 2.242
-
getXStream
@NonNull public static XStream2 getXStream()
Provides the XStream instance this class is using for serialization.- Returns:
- the XStream instance
- Since:
- 1.655
-
-