Skip to content

Instantly share code, notes, and snippets.

@mllrjb
Created October 12, 2016 21:12
Show Gist options
  • Save mllrjb/f3be6a1e6c63bcdf52bef84832563ce3 to your computer and use it in GitHub Desktop.
Save mllrjb/f3be6a1e6c63bcdf52bef84832563ce3 to your computer and use it in GitHub Desktop.
Jenkins init.groovy.d Ant Installer
import jenkins.model.*
import hudson.model.*
import hudson.tasks.*
import hudson.tools.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("hudson.tasks.Ant")
def versions = [
"ant-1.9": "1.9.7"
]
def installations = [];
for (v in versions) {
def installer = new Ant.AntInstaller(v.value)
def installerProps = new InstallSourceProperty([installer])
def installation = new Ant.AntInstallation(v.key, "", [installerProps])
installations.push(installation)
}
desc.setInstallations(installations.toArray(new Ant.AntInstallation[0]))
desc.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment