Hi,

I have a parametrized job that spawns Docker containers when it's running. 
This job is configured to store only the 10 most recent runs.
I would like to have the containers running for as long as the run that 
spawned them is stored in Jenkins.

So, the idea would be having something like a Listener that would execute 
the Docker commands to remove the containers when the build is about to be 
deleted.

I've thought of using the *PostBuild Groovy script* plugin to execute a 
listener and redefine the *onDeleted* method.

For example:

import hudson.model.Run;
import hudson.model.listeners.RunListener;
import hudson.Extension;

@Extension
public class DeleteListener extends RunListener<Run> {
      @Override
      void onDeleted(Run r) {
         println(r.getNumber())
      }
}



The problem with this approach is that when I execute the build, I get this 
error:

Groovy script failed:
org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No 
signature of method: DeleteListener.main() is applicable for argument types: 
([Ljava.lang.String;) values: [[]]
Possible solutions: wait(), wait(long), all(), any(), find(), wait(long, int
)



I'm not proficient with Java, neither Groovy; so I'm having a hard time 
understanding this error.

*My question* is how, if possible, can I execute some system commands 
whenever a certain build is about to be deleted.

Thanks and kind regards!

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/832ce598-477c-4fcf-ae79-4107ee2373d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to