<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://batmat.net/blog/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Blogounage - hudson</title>
  <link>http://batmat.net/blog/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Sat, 28 Jan 2012 08:26:48 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Configure Hudson CI Server to automatically disable itself when main SVN repositories become unreachable</title>
    <link>http://batmat.net/blog/post/2010/04/01/Configure-Jenkins-CI-Server-to-automatically-disable-itself-when-main-SVN-repositories-become-unreachable</link>
    <guid isPermaLink="false">urn:md5:271f8d68986fe9632a215748c83e6ed8</guid>
    <pubDate>Sun, 16 Jan 2011 12:57:00 +0100</pubDate>
    <dc:creator>batmat</dc:creator>
        <category>Technique</category>
        <category>ci</category><category>hudson</category><category>subversion</category><category>svn</category>    
    <description>    &lt;p&gt;&lt;em&gt;Note: I wrote this post some months ago, and just made it public since the problem making it impossible to use was fixed some weeks ago. In the meantime, you should also be aware that Hudson has recently been renamed to Jenkins, and its new house is now &lt;a href=&quot;http://jenkins-ci.org/&quot; title=&quot;http://jenkins-ci.org/&quot;&gt;http://jenkins-ci.org/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;


&lt;p&gt;Sometimes, we encounter erratic issues accessing our subversion repositories. Even apart from the server upgrade information that just dont reach the interested people, but only managers who didn't forward (since there're obviously not the ones that use the dev server...), we also have random problems like everyone.&lt;/p&gt;


&lt;h3&gt;The problem&lt;/h3&gt;

&lt;p&gt;When SVN becomes unreachable, every one starts receiving mails about it from Hudson... For example, last week-end I received 6000+ emails about that. So, I wrote this small &lt;a href=&quot;http://wiki.hudson-ci.org/display/HUDSON/Change+SCMTrigger+for+each+project+to+disable+during+the+night+and+the+week-end&quot;&gt;script to update all our jobs to not run during both the night and the week-end&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;But sure, this won't solve everything. For example, if the server goes down during a working-day, and you're not in front of your computer for some reason. When coming back to your box, you might discover the big amount of mails from Hudson, or even from the devs if you're in charge of operating the CI server.&lt;/p&gt;


&lt;p&gt;So I've been looking for a way to just automatically disable Hudson builds when a problem is detected.&lt;/p&gt;


&lt;h3&gt;The solution&lt;/h3&gt;

&lt;p&gt;For some days now, I've been playing with the Hudson script console since I discovered how greatly powerful it can be.&lt;/p&gt;


&lt;p&gt;My starting point was the hudson command used to prepare a shutdown. How to do it through the groovy console? I gave it here in &lt;a href=&quot;http://twitter.com/bmathus/status/11371789263&quot;&gt;one tweet: hudson.model.Hudson.instance.doQuietDown()&lt;/a&gt;. Once I found this, I just had to find a way to interact with the SVN inside the groovy/hudson console system and build around it a small groovy script.&lt;/p&gt;


&lt;p&gt;After some struggle about how to &lt;a href=&quot;https://wiki.svnkit.com/Printing_Out_A_Subversion_Repository_Tree&quot;&gt;programmatically use SVNKit (Subversion pure Java API)&lt;/a&gt;, and then &lt;a href=&quot;http://shrubbery.mynetgear.net/c/pages/viewpage.action?pageId=1802252#GroovyforJavaProgrammers-Anonymousinnerclassescanresultin%7B%7BUnknowntype%3AMETHODDEF%7D%7D&quot;&gt;how to use an anonymous class with Groovy&lt;/a&gt;, I was done.&lt;/p&gt;


&lt;p&gt;Here's the resulting script:&lt;/p&gt;
&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;java&quot;&gt;&lt;span class=&quot;co2&quot;&gt;import hudson.model.*&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;co2&quot;&gt;import org.tmatesoft.svn.core.*&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;co2&quot;&gt;import org.tmatesoft.svn.core.wc.*&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;amp;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;String&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; repoToCheck = &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;'svn://svn/scle'&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;'svn://svn:3691/pgih'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; MyHandler &lt;span class=&quot;kw2&quot;&gt;implements&lt;/span&gt; ISVNDirEntryHandler&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; def &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; handleDirEntry&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;SVNDirEntry dirEntry&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;co1&quot;&gt;// nothing&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
org.&lt;span class=&quot;me1&quot;&gt;tmatesoft&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;svn&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;core&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;internal&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;io&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;svn&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;SVNRepositoryFactoryImpl&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
Map&amp;lt;String, Throwable&amp;gt; problematicRepos = &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; LinkedHashMap&amp;lt;String, Throwable&amp;gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;amp;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;String&lt;/span&gt;&lt;/a&gt; repo:repoToCheck&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; SVNURL url = SVNURL.&lt;span class=&quot;me1&quot;&gt;parseURIDecoded&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;repo&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; SVNClientManager clientManager = SVNClientManager.&lt;span class=&quot;me1&quot;&gt;newInstance&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; SVNLogClient c = clientManager.&lt;span class=&quot;me1&quot;&gt;getLogClient&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;kw2&quot;&gt;try&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;co1&quot;&gt;// Special groovy anonymous class construct&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; def handler = &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; MyHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; c.&lt;span class=&quot;me1&quot;&gt;doList&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;url, SVNRevision.&lt;span class=&quot;me1&quot;&gt;UNDEFINED&lt;/span&gt;, SVNRevision.&lt;span class=&quot;me1&quot;&gt;HEAD&lt;/span&gt;, &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;, &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;, handler&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;kw2&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;amp;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Exception&lt;/span&gt;&lt;/a&gt; e&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; problematicRepos.&lt;span class=&quot;me1&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;repo, e&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;!problematicRepos.&lt;span class=&quot;me1&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=allinurl%3AMap+java.sun.com&amp;amp;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Map&lt;/span&gt;&lt;/a&gt;.&lt;span class=&quot;me1&quot;&gt;Entry&lt;/span&gt;&amp;lt;String, Throwable&amp;gt; entry:problematicRepos.&lt;span class=&quot;me1&quot;&gt;entrySet&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; println&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Problem accessing &lt;span class=&quot;es0&quot;&gt;\&amp;quot;&lt;/span&gt;&amp;quot;&lt;/span&gt;+entry.&lt;span class=&quot;me1&quot;&gt;getKey&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;+&lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es0&quot;&gt;\&amp;quot;&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;amp;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;String&lt;/span&gt;&lt;/a&gt; s = entry.&lt;span class=&quot;me1&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; println&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;s&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; println&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Disabling hudson build&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; hudson.&lt;span class=&quot;me1&quot;&gt;model&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Hudson&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;instance&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;doQuietDown&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;kw2&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; println&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;No problems with repos&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;h3&gt;How to install and configure it&lt;/h3&gt;

&lt;p&gt;Install the &lt;a href=&quot;http://wiki.hudson-ci.org/display/HUDSON/Groovy+plugin&quot;&gt;Groovy Plugin for Hudson&lt;/a&gt;. This way, you'll be able to add job directly written in Groovy.
Then create a job that will run every minute! (&quot;* * * * *&quot;) and put the script above inside an &quot;Execute system Groovy script&quot;.&lt;/p&gt;


&lt;p&gt;Then, configure the notification you like. It's probably a good idea to target admin email when this jobs fails. That's what I did.&lt;/p&gt;


&lt;p&gt;Important note: there used to be a difference of behaviour with classloading between &quot;groovy script console&quot; and &quot;groovy system script&quot; in a job. This made the script above unable to work. The good news if that it was fixed with &lt;a href=&quot;http://issues.hudson-ci.org/browse/HUDSON-6068&quot;&gt;Hudson 1.352 and HUDSON-6068&lt;/a&gt;. So the bad news is that you can't use this technique if you're using an older version (time to upgrade? ;-)).&lt;/p&gt;


&lt;h3&gt;Possible improvements&lt;/h3&gt;

&lt;p&gt;Sure the script isn't perfect, here's a few thought of what's currently missing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;At the moment, watched repositories are explicitly declared in the script. Maybe it would be more interesting to iterate through the whole list of jobs to find the actual used repositories. But I feel this approach might be a problem: if only one job is failing, maybe the team HAS to be notified. You're not going to disable the whole hudson instance (or even cluster) for only one job failing, right?&lt;/li&gt;
&lt;li&gt;About svn&amp;nbsp;:
&lt;ul&gt;
&lt;li&gt;this is the only supported scm in the script above&lt;/li&gt;
&lt;li&gt;Only the &quot;svn&quot; protocol is supposed to be supported. If you want to access http exposed repos, then you might have to also initialize the webdav subsystem by calling &lt;code&gt;DAVRepository.setup()&lt;/code&gt; first.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Groovify&lt;/em&gt; the script a bit. I first wrote it in Java, and then adapted it a bit to be more groovy-like, but my experience in Groovy is only about two weeks, so please be indulgent.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;</description>
    
    
    
          <comments>http://batmat.net/blog/post/2010/04/01/Configure-Jenkins-CI-Server-to-automatically-disable-itself-when-main-SVN-repositories-become-unreachable#comment-form</comments>
      <wfw:comment>http://batmat.net/blog/post/2010/04/01/Configure-Jenkins-CI-Server-to-automatically-disable-itself-when-main-SVN-repositories-become-unreachable#comment-form</wfw:comment>
      <wfw:commentRss>http://batmat.net/blog/feed/rss2/comments/317</wfw:commentRss>
      </item>
    
  <item>
    <title>[Hudson] How to set a private maven repository by job and easily be able to delete them</title>
    <link>http://batmat.net/blog/post/2009/10/09/%5BHudson%5D-How-to-set-a-private-maven-repository-by-job-and-easily-be-able-to-delete-them</link>
    <guid isPermaLink="false">urn:md5:1eb535bfb6545a2edf56497456f1fc97</guid>
    <pubDate>Fri, 09 Oct 2009 10:17:00 +0200</pubDate>
    <dc:creator>batmat</dc:creator>
        <category>Technique</category>
        <category>hudson</category><category>maven</category>    
    <description>    &lt;p&gt;When building maven projects with hudson, there's some &lt;a href=&quot;http://www.sonatype.com/people/2009/01/maven-continuous-integration-best-practices/&quot;&gt;common best practices about maven repositories handling&lt;/a&gt; :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;isolate maven repositories between jobs&lt;/li&gt;
&lt;li&gt;regularly purge repositories&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;The problem&lt;/h3&gt;

&lt;p&gt;The basic way to do it is to activate the hudson per-job option : &quot;Use private Maven repository&quot;. But the thing is you have to do it for EVERY new job you add. There is no way inside hudson to activate it globally.&lt;/p&gt;


&lt;h3&gt;Documented solution&lt;/h3&gt;

&lt;p&gt;If you look at hudson help for this option, you'll see a link to a simple solution that &lt;a href=&quot;http://www.nabble.com/Hudson-on-2%2C-4%2C-8%2C-16-core-boxes--tt17767865.html#a17782153&quot;&gt;specify the repository directly in the maven settings.xml file&lt;/a&gt;.
The tip is to redefine the localRepository tag inside settings with this special value :&lt;/p&gt;
&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;localRepository&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;${env.WORKSPACE}/m2_repo&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/localRepository&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This way, you're done with the first best practice : &lt;em&gt;isolate maven repositories&lt;/em&gt;. But not yet with the &lt;em&gt;regularly purge repositories&lt;/em&gt; one.
Actually, using this option will put the m2_repo inside each hudson job workspace. So, finding and deleting them could become a bit cumbersome. You'd have to cron something like &lt;code&gt;find . -name m2_repo -exec rm -rf &quot;{}&quot; \;&lt;/code&gt;.&lt;/p&gt;


&lt;h3&gt;Even better&lt;/h3&gt;

&lt;p&gt;As you might have understood, I was not thoroughly satisfied with this solution. I wanted to be able to &lt;em&gt;really easily&lt;/em&gt; delete the repositories. So I just changed the option above to have them all inside the same root directory under ~/.m2/repositories, one per job.&lt;/p&gt;


&lt;p&gt;Quite simple in fact, instead, just use :&lt;/p&gt;
&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;localRepository&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;/some/path/.m2/repositories/${env.JOB_NAME}/repository&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/localRepository&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This way, the only thing you have to put in the cron job is &lt;code&gt;rm -rf /some/path/.m2/repositories/&lt;/code&gt;. A bit more straightforward, isn't it? &lt;img src=&quot;/dotclear/themes/default/smilies/smile.png&quot; alt=&quot;:-)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Hope this helps.&lt;/p&gt;</description>
    
    
    
          <comments>http://batmat.net/blog/post/2009/10/09/%5BHudson%5D-How-to-set-a-private-maven-repository-by-job-and-easily-be-able-to-delete-them#comment-form</comments>
      <wfw:comment>http://batmat.net/blog/post/2009/10/09/%5BHudson%5D-How-to-set-a-private-maven-repository-by-job-and-easily-be-able-to-delete-them#comment-form</wfw:comment>
      <wfw:commentRss>http://batmat.net/blog/feed/rss2/comments/309</wfw:commentRss>
      </item>
    
</channel>
</rss>
