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
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionList<ItemListener>
all()
All the registeredItemListener
s.static void
checkBeforeCopy
(Item src, ItemGroup parent) Call before a job is copied into a new parent, to allow theItemListener
implementations the ability to veto the copy operation before it starts.static void
checkBeforeDelete
(Item item) static void
fireLocationChange
(Item rootItem, String oldFullName) static void
fireOnCopied
(Item src, Item result) static void
fireOnCreated
(Item item) static void
fireOnDeleted
(Item item) static void
fireOnUpdated
(Item item) void
void
onCheckCopy
(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.void
onCheckDelete
(Item item) Called before an item is deleted, providing the ability to veto the deletion operation before it starts.void
Called after a new job is created by copying from an existing job.void
Called after a new job is created and added toJenkins
, before the initial configuration page is provided.void
Called right before a job is going to be deleted.void
onLoaded()
Called after all the jobs are loaded from disk intoJenkins
object.void
onLocationChanged
(Item item, String oldFullName, String newFullName) Called after an item’s fully-qualified location has changed.void
Called after a job is renamed.void
Called after a job has its configuration updated.void
register()
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 intoJenkins
object. -
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 putExtension
on your class to have it auto-registered.Registers this instance to Hudson and start getting notifications. -
all
All the registeredItemListener
s. -
fireOnCopied
-
checkBeforeCopy
Call before a job is copied into a new parent, to allow theItemListener
implementations 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:
Failure
InterruptedException
-
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
-
Extension
on your class to have it auto-registered.