Last active
November 13, 2018 11:22
-
-
Save mkutz/97b7b3dda945dfba27e495d6349b9fec to your computer and use it in GitHub Desktop.
Configure JDK installations in Jenkins using a post-initialization script (https://wiki.jenkins.io/display/JENKINS/Post-initialization+script)
This file contains hidden or 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.model.JDK | |
/* | |
* Configure the locations of multiple JDKs | |
* Note that this won't install anything, it just makes Jenkins aware of JDK installations | |
*/ | |
Jenkins.instance.getDescriptor(JDK).setInstallations( | |
new JDK("11", "/usr/lib/jvm/java-11-openjdk-amd64/"), | |
new JDK("8", "/usr/lib/jvm/java-8-openjdk-amd64/") | |
) |
This file contains hidden or 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 { | |
jdk "11" | |
} | |
stages { | |
stage("Use java") { | |
steps { | |
echo env.JAVA_HOME | |
sh "java -version" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment