Child pages
  • Change JVM Options in all Maven tasks of Freestyle Jobs

Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

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 : "+item.name);
    // Find current recipients defined in project
    println(">FREESTYLE PROJECT");
    for (builder in item.builders){
      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);
        item.buildersList.replace(newBuilder);
      }
    }
    println("\n=======\n");
  }
}
  • No labels