Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Change JVM Options in all Maven tasks of Freestyle Jobs

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.items) {
  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);
        def newBuilder = new Maven(builder.targets,builder.mavenName,builder.pom,builder.@properties,newJvmOptions,builder.usePrivateRepository);
        item.buildersList.replace(newBuilder);
      }
    }
    println("\n=======\n");
  }
}

Copyright © Eclipse Foundation, Inc. All Rights Reserved.