The Script can be used as an event listener for Tempo Plans (Create, Edit, Delete).
import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.atlassian.event.api.EventListener import com.atlassian.event.api.EventPublisher import com.atlassian.jira.event.type.EventType import com.atlassian.jira.event.type.EventTypeManager import com.atlassian.jira.component.ComponentAccessor import com.tempoplugin.jira.plan.* import com.tempoplugin.jira.plan.core.ao.AOAllocationService import com.tempoplugin.jira.plan.core.api.Allocation import com.tempoplugin.planner.api.AllocationDto import com.tempoplugin.planner.api.event.AllocationEvent import com.tempoplugin.planner.api.event.AllocationCreatedEvent import com.tempoplugin.planner.api.event.AllocationDeletedEvent import com.tempoplugin.planner.api.event.AllocationUpdatedEvent import com.onresolve.scriptrunner.runner.util.UserMessageUtil import com.tempoplugin.platform.api.event.Event import static groovyx.net.http.ContentType.* import org.apache.log4j.Level import org.apache.log4j.Logger def myLog = Logger.getLogger("com.onresolve.jira.groovy") myLog.setLevel(Level.DEBUG) @WithPlugin("is.origo.jira.tempo-plugin") AllocationEvent event2 = event myLog.info("Received event ${event2}") def AllocationEventName = event2.getClass().getSimpleName() myLog.info("Received event of type ${event2.getClass().getSimpleName()}") if(event2 instanceof AllocationCreatedEvent){ myLog.info("A new allocation with the ID : ${event.allocation.id} has been created") } if(event2 instanceof AllocationDeletedEvent){ myLog.info("The allocation with ID: ${event.allocation.id} has been deleted") } if(event2 instanceof AllocationUpdatedEvent){ myLog.info("The allocation with the ID : ${event.allocation.id} has been updated") } |
Other parameters of the allocation event are:
id=184 parent=null planItemId=10029 planItemType=ISSUE assigneeKey=paul assigneeType=USER description=PLan for Paul secondsPerDay=7200, shouldIncludeNonWorkingDays=false creatorKey=john updaterKey=john startDate=2021-01-19 endDate=2021-01-23 recurrenceEndDate=2021-01-23 rule=NEVER |