@Extension
public class BlockBuildItemListener
extends hudson.model.listeners.ItemListener
Constructor and Description |
---|
BlockBuildItemListener() |
Modifier and Type | Method and Description |
---|---|
void |
onDeleted(hudson.model.Item item)
Handles the deleted event.
|
void |
onRenamed(hudson.model.Item item,
String oldName,
String newName)
Handles the renamed event.
|
public void onDeleted(hudson.model.Item item)
onDeleted
in class hudson.model.listeners.ItemListener
item
- the item being deleted
1. Checks that item is of type AbstractProject
2. Gets the AbstractProject and name from item.
3. Loops through all AbstractProjects in Jenkins.
4. Do NOT update the project that is being deleted. Doing so will
cause the project to not be deleted. It will be disabled instead.
5. Get the BlockBuildJobProperty from the current project.
6. Because BlockBuildJobProperty is immutable, create a new BlockBuildJobProperty, with the deleted project removed.
7. Remove the old BlockBuildJobProperty from the current project and add the new one in.
8. Log a message if an error.public void onRenamed(hudson.model.Item item, String oldName, String newName)
onRenamed
in class hudson.model.listeners.ItemListener
item
- the item being renamedoldName
- the old name of the itemnewName
- the new name of the item
1. Checks that item is of type AbstractProject
2. Gets the AbstractProject and name from item.
3. Loops through all AbstractProjects in Jenkins.
4. Get the BlockBuildJobProperty from the current project.
5. Because BlockBuildJobProperty is immutable, create a new BlockBuildJobProperty, with the project renamed.
6. Remove the old BlockBuildJobProperty from the current project and add the new one in.
7. Log a message if an error.Copyright © 2016–2017. All rights reserved.