Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Allow broken build claiming on every jobs"

(New page: After installing the Hudson Claim Plugin, you have to configure each job by manually checking the "allow broken build claiming" option. Obviously, it can be a bit cumbersome. But here co...)
 
 
Line 5: Line 5:
 
Don't hesitate to give me feedback (and backup your config before playing with those scripts, as always).  
 
Don't hesitate to give me feedback (and backup your config before playing with those scripts, as always).  
  
import hudson.model.* import hudson.maven.* import hudson.tasks.*  
+
<pre>
 +
import hudson.model.*  
 +
import hudson.maven.*  
 +
import hudson.tasks.*  
  
 
for(item in Hudson.instance.items) {  
 
for(item in Hudson.instance.items) {  
Line 13: Line 16:
 
  for(p in item.publishers )
 
  for(p in item.publishers )
 
  {
 
  {
  if(p instanceof hudson.plugins.claim.ClaimPublisher)
+
  if(p instanceof hudson.plugins.claim.ClaimPublisher)
  {
+
  {
    hasClaim = true;
+
    hasClaim = true;
  }
+
  }
 
  }
 
  }
 
  if(!hasClaim)
 
  if(!hasClaim)
 
  {
 
  {
  println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Adding claim right to $item.name")
+
  println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Adding claim right to $item.name")
  item.getPublishersList().add(new  hudson.plugins.claim.ClaimPublisher() );
+
  item.getPublishersList().add(new  hudson.plugins.claim.ClaimPublisher() );
  item.save()
+
  item.save()
 
  }
 
  }
  
 
}  
 
}  
 
+
</pre>
 
Known quirk:  
 
Known quirk:  
  
    Funnily, if I run this script many times, I see the same item coming back. But when I check inside the job configuration, the checkbox was correctly modified. I don't know where it comes from yet. If you have any idea, just let me know.
+
When running this script many times, I see the same item coming back. But when I check inside the job configuration, the checkbox was correctly modified. I don't know where it comes from yet. If you have any idea, just let me know.

Latest revision as of 21:08, 10 December 2012

After installing the Hudson Claim Plugin, you have to configure each job by manually checking the "allow broken build claiming" option.

Obviously, it can be a bit cumbersome. But here comes the great groovy script console again. With the following simple script, you can activate the option on every jobs of your server in just one go.

Don't hesitate to give me feedback (and backup your config before playing with those scripts, as always).

import hudson.model.* 
import hudson.maven.* 
import hudson.tasks.* 

for(item in Hudson.instance.items) { 

  println("job $item.name")
 hasClaim = false;
 for(p in item.publishers )
 {
  if(p instanceof hudson.plugins.claim.ClaimPublisher)
  {
    hasClaim = true;
  }
 }
 if(!hasClaim)
 {
  println(">>>>>>>> Adding claim right to $item.name")
  item.getPublishersList().add(new  hudson.plugins.claim.ClaimPublisher() );
  item.save()
 }

} 

Known quirk:

When running this script many times, I see the same item coming back. But when I check inside the job configuration, the checkbox was correctly modified. I don't know where it comes from yet. If you have any idea, just let me know.

Back to the top