Last active
July 4, 2020 10:42
-
-
Save mllrjb/2454f501777cf770e6586e0c84dc265c to your computer and use it in GitHub Desktop.
Jenkins init.groovy.d JDK Installer
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 jenkins.model.* | |
import hudson.model.* | |
import hudson.tools.* | |
def inst = Jenkins.getInstance() | |
def desc = inst.getDescriptor("hudson.model.JDK") | |
def versions = [ | |
"jdk8": "jdk-8u102-oth-JPR" | |
] | |
def installations = []; | |
for (v in versions) { | |
def installer = new JDKInstaller(v.value, true) | |
def installerProps = new InstallSourceProperty([installer]) | |
def installation = new JDK(v.key, "", [installerProps]) | |
installations.push(installation) | |
} | |
desc.setInstallations(installations.toArray(new JDK[0])) | |
desc.save() | |
// Required: enter credentials at http://l:8080/descriptorByName/hudson.tools.JDKInstaller/enterCredential |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment