Hi,

from time to time we remove old Mercurial repositories. During this
process, a small Groovy program removes all Jenkins jobs which are
configured to poll one of those repositories.

This works quite well, however, it doesn't currently remove the
workspaces and mercurial caches of the removed jobs from all slaves.
Unfortunately, I have no clue as to how to enhance the program to do
exactly this, so any help would be appreciated.

import hudson.model.*
import hudson.scm.*
import hudson.plugins.mercurial.*

// Get the repo from the command line and split it at /
repo = args[0]
(type, name) = repo.split("/")

// Iterate over all jobs
for(item in Hudson.instance.items)
{
    // Does the jobs have a Mercurial configuration?
    if (item.getScm() instanceof MercurialSCM)
    {
        // Get the repository Url
        MercurialSCM hg = (MercurialSCM)item.getScm()
        source = hg.getSource()

        // Does the Url contain our repository name?
        if (source.contains(repo))
        {
            // Delete the job
            println ("     Removing job $item.name for $type repository
$name...")
            item.delete()
        }
    }
}

Thanks in advance...

    Dirk
-- 

*Dirk Heinrichs*, Senior Systems Engineer, Infrastructure
*Recommind GmbH*, Von-Liebig-Straße 1, 53359 Rheinbach
*Tel*: +49 2226 1596666 1149
*Email*: d...@recommind.com <mailto:d...@recommind.com>
*Skype*: dirk.heinrichs.recommind
www.recommind.com <http://www.recommind.com>


http://www.recommind.com

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to