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
public class ItemListener extends Object implements ExtensionPoint
Receives notifications about CRUD operations ofItem
.- Since:
- 1.74
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description ItemListener()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static 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
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
onBeforeShutdown()
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
onCopied(Item src, Item item)
Called after a new job is created by copying from an existing job.void
onCreated(Item item)
Called after a new job is created and added toJenkins
, before the initial configuration page is provided.void
onDeleted(Item item)
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
onRenamed(Item item, String oldName, String newName)
Called after a job is renamed.void
onUpdated(Item item)
Called after a job has its configuration updated.void
register()
Deprecated.as of 1.286 putExtension
on your class to have it auto-registered.
-
-
-
Method Detail
-
onCreated
public void onCreated(Item item)
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
public void onCheckCopy(Item src, ItemGroup parent) throws Failure
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
public void onCopied(Item src, Item item)
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.
-
onDeleted
public void onDeleted(Item item)
Called right before a job is going to be deleted. At this point the data files of the job is already gone.
-
onRenamed
public void onRenamed(Item item, String oldName, String newName)
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
public void onLocationChanged(Item item, String oldFullName, String newFullName)
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:
Items.computeRelativeNamesAfterRenaming(java.lang.String, java.lang.String, java.lang.String, hudson.model.ItemGroup)
-
onUpdated
public void onUpdated(Item item)
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 public void 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
public static ExtensionList<ItemListener> all()
All the registeredItemListener
s.
-
checkBeforeCopy
public static void checkBeforeCopy(Item src, ItemGroup parent) throws Failure
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
public static void fireOnCreated(Item item)
-
fireOnUpdated
public static void fireOnUpdated(Item item)
-
fireOnDeleted
public static void fireOnDeleted(Item item)
- Since:
- 1.548
-
fireLocationChange
public static void fireLocationChange(Item rootItem, String oldFullName)
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
-
-