Skip to content

Instantly share code, notes, and snippets.

@arbabnazar
Forked from mllrjb/nodejs-installers.groovy
Created August 23, 2017 14:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save arbabnazar/052e056a077e18fcfe6c333537f18eb1 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