Child pages
  • Change JVM Options in all Maven tasks of Freestyle Jobs
Skip to end of metadata
Go to start of metadata

This script find all Maven Tasks registered in freestyle jobs and replace JVM Options by a new value.

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

def newJvmOptions="-Xshare:auto -Xms64m -Xmx512m -XX:MaxPermSize=256M"

// For each project
for(item in Hudson.instance.allItems) {
  if(item instanceof FreeStyleProject) {
    println("JOB : ";
    // Find current recipients defined in project
    println(">FREESTYLE PROJECT");
    for (builder in{
      println(">> "+builder);
      if (builder instanceof Maven) {
        println(">>MAVEN BUILDER");
        println(">>TARGETS : "+builder.targets);
        println(">>NAME : "+builder.mavenName);
        println(">>POM : "+builder.pom);
        // .properties is overridden by groovy
        println(">>PROPERTIES : "+builder.@properties);
        println(">>JVM-OPTIONS : "+builder.jvmOptions);
        println(">>USE PRIVATE REPO : "+builder.usePrivateRepository);
        println(">>USER SETTINGS : "+builder.settings);
        println(">>GLOBAL SETTINGS : "+builder.globalSettings);
        def newBuilder = new Maven(builder.targets,builder.mavenName,builder.pom,builder.@properties,newJvmOptions,builder.usePrivateRepository,builder.settings,builder.globalSettings);
  • No labels