I think this is a matter of context. That has to be like a "system" groovy
script.

Also, if that doesn't work, you should probably just create a plugin. You
have already written what you need, and that will let you manage it
cleanlier (writing tests, versioning…).

Cheers

Le 6 sept. 2016 6:32 PM, "Adri CS" <[email protected]> a Ă©crit :

> 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-users/832ce598-477c-4fcf-ae79-4107ee2373d7%40googlegroups.
> com
> <https://groups.google.com/d/msgid/jenkinsci-users/832ce598-477c-4fcf-ae79-4107ee2373d7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS6fBXyPnNgZZFyf_e30Zs%2Br3XsrW1aNak2JgYbmjuZxhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to