Hello.
I am writing a plugin for cancelling tasks which are in the queue on a few
conditions.
One of this conditions is:
* The task should be cancelled previously to get an executor for build if
others conditions are true.
The final goal is cancelling the task if there was not scm changes since
last build (if it was sucessfully).
I've just write a QueueListener extension, but I didn't sucessfuly on
cancel a job.
This is the code:
@Extension
public class CancelJobPlugin
extends QueueListener {
private final static Logger LOGGER =
Logger.getLogger(CancelJobPlugin.class.getName());
@Override
public void onLeaveBuildable( final BuildableItem bi ) {
final Queue queue = Jenkins.getInstance().getQueue();
try {
// This doesn't work
queue.cancel( bi.task );
// This doesn't work
queue.doCancelItem( bi.getId() );
LOGGER.info( "CANCELLED..." );
} catch ( final IOException | ServletException cause ) {
LOGGER.log( Level.SEVERE, "ERROR CANCELLING...", cause );
}
}
}
Well, I don't know why doesn't work. The 'CANCELLED' message if showed, but
the task gets an executor and the build starts.
I tried too with the onLeft method.
How can I cancel a task previously to get an executor?
May be with another extension?
Thank you for your help.
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/4e5db48b-0fda-424e-bd23-fb245fb9855c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.