Package hudson.model.listeners
Class ItemListener
java.lang.Object
hudson.model.listeners.ItemListener
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
ArtifactArchiver.Migrator,BuildTrigger.DescriptorImpl.ItemListenerImpl,DisplayNameListener,Fingerprint.ProjectRenameListener,Job.LastItemListener,Job.SubItemBuildsLocationImpl,LazyBuildMixIn.ItemListenerImpl,ListView.Listener,ReverseBuildTrigger.ItemListenerImpl
Receives notifications about CRUD operations of
Item.- Since:
- 1.74
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionList<ItemListener> all()All the registeredItemListeners.static voidcheckBeforeCopy(Item src, ItemGroup parent) Call before a job is copied into a new parent, to allow theItemListenerimplementations the ability to veto the copy operation before it starts.static voidcheckBeforeDelete(Item item) static voidfireLocationChange(Item rootItem, String oldFullName) static voidfireOnCopied(Item src, Item result) static voidfireOnCreated(Item item) static voidfireOnDeleted(Item item) static voidfireOnUpdated(Item item) voidvoidonCheckCopy(Item src, ItemGroup parent) Called before a job is copied into a new parent, providing the ability to veto the copy operation before it starts.voidonCheckDelete(Item item) Called before an item is deleted, providing the ability to veto the deletion operation before it starts.voidCalled after a new job is created by copying from an existing job.voidCalled after a new job is created and added toJenkins, before the initial configuration page is provided.voidCalled right before a job is going to be deleted.voidonLoaded()Called after all the jobs are loaded from disk intoJenkinsobject.voidonLocationChanged(Item item, String oldFullName, String newFullName) Called after an item’s fully-qualified location has changed.voidCalled after a job is renamed.voidCalled after a job has its configuration updated.voidregister()Deprecated.
-
Constructor Details
-
ItemListener
public ItemListener()
-
-
Method Details
-
onCreated
Called after a new job is created and added toJenkins, before the initial configuration page is provided.This is useful for changing the default initial configuration of newly created jobs. For example, you can enable/add builders, etc.
-
onCheckCopy
Called before a job is copied into a new parent, providing the ability to veto the copy operation before it starts.- Parameters:
src- the item being copiedparent- the proposed parent- Throws:
Failure- to veto the operation.- Since:
- 2.51
-
onCopied
Called after a new job is created by copying from an existing job. For backward compatibility, the default implementation of this method callsonCreated(Item). If you choose to handle this method, think about whether you want to call super.onCopied or not.- Parameters:
src- The source item that the new one was copied from. Never null.item- The newly created item. Never null.- Since:
- 1.325
Before this version, a copy triggered
onCreated(Item).
-
onLoaded
public void onLoaded()Called after all the jobs are loaded from disk intoJenkinsobject. -
onCheckDelete
Called before an item is deleted, providing the ability to veto the deletion operation before it starts.- Parameters:
item- the item being deleted- Throws:
Failure- to veto the operation.InterruptedException- If a blocking condition was interrupted, also vetoing the operation.- Since:
- 2.470
-
onDeleted
Called right before a job is going to be deleted. At this point the data files of the job is already gone. -
onRenamed
Called after a job is renamed. Most implementers should rather useonLocationChanged(hudson.model.Item, java.lang.String, java.lang.String).- Parameters:
item- The job being renamed.oldName- The old name of the job.newName- The new name of the job. Same asItem.getName().- Since:
- 1.146
-
onLocationChanged
Called after an item’s fully-qualified location has changed. This might be because:- This item was renamed.
- Some ancestor folder was renamed.
- This item was moved between folders (or from a folder to Jenkins root or vice-versa).
- Some ancestor folder was moved.
onRenamed(hudson.model.Item, java.lang.String, java.lang.String)will already have been called on this item or an ancestor. And where applicable,onLocationChanged(hudson.model.Item, java.lang.String, java.lang.String)will already have been called on its ancestors.This method should be used (instead of
onRenamed(hudson.model.Item, java.lang.String, java.lang.String)) by any code which seeks to keep (absolute) references to items up to date: if a persisted reference matchesoldFullName, replace it withnewFullName.- Parameters:
item- an item whose absolute position is now differentoldFullName- the formerItem.getFullName()newFullName- the currentItem.getFullName()- Since:
- 1.548
- See Also:
-
onUpdated
Called after a job has its configuration updated.- Since:
- 1.460
-
onBeforeShutdown
public void onBeforeShutdown()- Since:
- 1.446 Called at the beginning of the orderly shutdown sequence to allow plugins to clean up stuff
-
register
Deprecated.as of 1.286 putExtensionon your class to have it auto-registered.Registers this instance to Hudson and start getting notifications. -
all
All the registeredItemListeners. -
fireOnCopied
-
checkBeforeCopy
Call before a job is copied into a new parent, to allow theItemListenerimplementations the ability to veto the copy operation before it starts.- Parameters:
src- the item being copiedparent- the proposed parent- Throws:
Failure- if the copy operation has been vetoed.- Since:
- 2.51
-
fireOnCreated
-
fireOnUpdated
-
checkBeforeDelete
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void checkBeforeDelete(Item item) throws Failure, InterruptedException - Throws:
FailureInterruptedException
-
fireOnDeleted
- Since:
- 1.548
-
fireLocationChange
CallsonRenamed(hudson.model.Item, java.lang.String, java.lang.String)andonLocationChanged(hudson.model.Item, java.lang.String, java.lang.String)as appropriate.- Parameters:
rootItem- the topmost item whose location has just changedoldFullName- the previousItem.getFullName()- Since:
- 1.548
-
Extensionon your class to have it auto-registered.