Skip to content

Instantly share code, notes, and snippets.

@mllrjb
Last active November 29, 2017 08:51
Show Gist options
  • Save mllrjb/8c8c30d9bd54532bf6e6a62031e7e3a6 to your computer and use it in GitHub Desktop.
Save mllrjb/8c8c30d9bd54532bf6e6a62031e7e3a6 to your computer and use it in GitHub Desktop.
Jenkins init.groovy.d Nodejs installer script
import jenkins.model.*
import hudson.model.*
import jenkins.plugins.nodejs.tools.*
import hudson.tools.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("jenkins.plugins.nodejs.tools.NodeJSInstallation")
def versions = [
"nodejs-6.x": "6.7.0",
"nodejs-4.x": "4.6.0",
]
def installations = [];
for (v in versions) {
def installer = new NodeJSInstaller(v.value, "", 100)
def installerProps = new InstallSourceProperty([installer])
def installation = new NodeJSInstallation(v.key, "", [installerProps])
installations.push(installation)
}
desc.setInstallations(installations.toArray(new NodeJSInstallation[0]))
desc.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment