One more question (hope you won't mind). I've been trying to find the state of the current task (probably not the best way to do this):
import org.sonatype.nexus.scheduling.TaskState
import org.sonatype.nexus.scheduling.Task
import org.sonatype.nexus.scheduling.TaskInfo
import org.sonatype.nexus.scheduling.CurrentState
TaskScheduler taskScheduler = container.lookup(TaskScheduler.class.getName())
TaskInfo existingTask = taskScheduler.listsTasks().find { TaskInfo taskInfo ->
taskInfo.name == "0-test"
}
sleep(10000)
if (existingTask) {
log.debug("currentState: ${existingTask.getCurrentState()}")
}
```
When I run this task (which I named "0-test"), I would expect it to log "RUNNING_CANCELED", if I click the "Stop" button to stop the task within 10 seconds of starting the task, but it always gives me:
021-06-04 13:58:24,704+0200 DEBUG [quartz-10-thread-9] *SYSTEM org.sonatype.nexus.internal.script.ScriptTask - currentState: CurrentStateImpl{state=RUNNING, nextRun=null, future=org.sonatype.nexus.quartz.internal.task.QuartzT
askFuture@28ebb670}
Question: how would I get the RUNNING_CANCELED state or have the custom script listen to the Stop button? When I click on the Stop button, I do get a message that the task is stopped.
Thanks,
Mariska.