Skip to content

Instantly share code, notes, and snippets.

@tszpinda
Created October 9, 2015 12:55
Show Gist options
  • Save tszpinda/53e958cf80b0f532c787 to your computer and use it in GitHub Desktop.
Save tszpinda/53e958cf80b0f532c787 to your computer and use it in GitHub Desktop.
install maven in jenkins via groovy
# command line to execute.
java -jar jenkins-cli.jar -s http://localhost:8080/ groovy install-maven-in-jenkins.groovy
// install maven
// file: maven3.groovy
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
a=Jenkins.instance.getExtensionList(hudson.tasks.Maven.DescriptorImpl.class)[0];
b=(a.installations as List);
b.add(new hudson.tasks.Maven.MavenInstallation("MAVEN3", "/home/jenkins/apache-maven/apache-maven-3.2.3", []));
a.installations=b
a.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment