Tobi
Tobi

Reputation: 71

configure Jenkins "Global Tool Configuration" using CLI / groovy

Is there a way to configure ANT- and MAVEN-Installations using CLI? For the JDK there is:

dis = new hudson.model.JDK.DescriptorImpl();
dis.setInstallations( new hudson.model.JDK("JDK8", "/usr/lib/jvm/java-1.8-openjdk"));

Tobi

Upvotes: 4

Views: 3985

Answers (2)

Singhak
Singhak

Reputation: 8896

It the way to set maven using Groovy:

    def inst = Jenkins.getInstance()    
    def desc = inst.getDescriptor("hudson.tasks.Maven")
    def minst =  new hudson.tasks.Maven.MavenInstallation("Maven_name", "maven_path");
    desc.setInstallations(minst)
    desc.save()

Upvotes: 3

denis.solonenko
denis.solonenko

Reputation: 11775

You can find out the corresponding descriptors by manually changing Global Tool Configuration and then looking at the xml config files created in JENKINS_HOME.

For example, for Maven it must be hudson.tasks.Maven.DescriptorImpl and for Ant - hudson.tasks.Ant.DescriptorImpl

Upvotes: 2

Related Questions