Skip to content

Instantly share code, notes, and snippets.

@mllrjb
Last active July 4, 2020 10:42
Show Gist options
  • Save mllrjb/2454f501777cf770e6586e0c84dc265c to your computer and use it in GitHub Desktop.
Save mllrjb/2454f501777cf770e6586e0c84dc265c to your computer and use it in GitHub Desktop.
Jenkins init.groovy.d JDK Installer
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