Last active
November 12, 2018 10:31
-
-
Save mkutz/34aa401592f83c42f25b5ea681d41b48 to your computer and use it in GitHub Desktop.
Configure Maven installations in Jenkins using a post-initialization script (https://wiki.jenkins.io/display/JENKINS/Post-initialization+script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hudson.tasks.Maven.MavenInstallation | |
import hudson.tasks.Maven.MavenInstaller | |
import hudson.tools.InstallSourceProperty | |
/* | |
* add Maven installations to global tool configrations | |
*/ | |
hudson.tasks.Maven.DescriptorImpl mavenPlugin = Jenkins.instance.getExtensionList(hudson.tasks.Maven.DescriptorImpl).first() | |
mavenPlugin.installations = [ | |
new MavenInstallation('3.6.0', null, [new InstallSourceProperty([new MavenInstaller('3.6.0')])]), | |
new MavenInstallation('3.2.5', null, [new InstallSourceProperty([new MavenInstaller('3.2.5')])]), | |
new MavenInstallation('3.1.1', null, [new InstallSourceProperty([new MavenInstaller('3.1.1')])]) | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
tools { | |
maven "3.2.5" | |
} | |
stages { | |
stage("Use maven") { | |
steps { | |
sh "mvn --version" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment