-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NodeJS not installing with 1.0 plugin #30
Comments
nickdgriffin
changed the title
NodeJS not installing
NodeJS not installing with 1.0 plugin
Jan 31, 2017
@nickdgriffin @anton-kasperovich There error in adop_nodejs.groovy line #27 is def nodeJSPluginInstance = NodeJSPlugin.instance() NodeJSPlugin has no instance method. I fixed it with the following. def nodeJSPluginInstance = new NodeJSPlugin().getInstallations() This is the sample script that I use to test this in Jenkins Script console. import hudson.model.*;
import jenkins.model.*;
import hudson.tools.*;
import jenkins.plugins.nodejs.*;
import jenkins.plugins.nodejs.tools.*;
// Check if enabled
def env = System.getenv()
if (!env['ADOP_NODEJS_ENABLED'].toBoolean()) {
println "--> ADOP NodeJS Disabled"
return
}
// Variables
def nodejs_version = env['NODEJS_VERSION'] ?: '8.5.0'
def nodejs_global_packages = env['NODEJS_GLOBAL_PACKAGES']
def nodejs_packages_refresh_hours = env['NODEJS_PACKAGES_REFRESH_HOURS'].toLong()
println nodejs_version
println nodejs_global_packages
println nodejs_packages_refresh_hours
// Constants
def instance = Jenkins.getInstance()
// NodeJS
println "--> Configuring NodeJS"
def nodeJSPluginInstance = new NodeJSPlugin().getInstallations()
def nodejsInstaller = new NodeJSInstaller(nodejs_version,nodejs_global_packages,nodejs_packages_refresh_hours)
def installSourceProperty = new InstallSourceProperty([nodejsInstaller])
def nodejs_inst = new NodeJSInstallation(
"ADOP NodeJS", // Name
"", // Home
[installSourceProperty]
)
// Only add ADOP NodeJS if it does not exist - do not overwrite existing config
def nodejs_installations = nodeJSPluginInstance
def nodejs_inst_exists = false
nodejs_installations.each {
installation = (NodeJSInstallation) it
if ( nodejs_inst.getName() == installation.getName() ) {
nodejs_inst_exists = true
println("Found existing installation: " + installation.getName())
}
}
if (!nodejs_inst_exists) {
nodejs_installations += nodejs_inst
nodeJSPluginInstance.setInstallations((NodeJSInstallation[]) nodejs_installations)
nodeJSPluginInstance.save()
} Should I create a Pull Request? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was messing around with the latest from adop-docker-compose and noticed this error:
I also couldn't see the default NodeJS installation either. The above suggests the plugin has changed and the adop_nodejs.groovy script needs updating perhaps.
I will add that I was installing all sorts and updated everything so my NodeJS plugin has ended up at version 1.0 - so this might be something we need to care about in the future when we upgrade, rather than right now.
The text was updated successfully, but these errors were encountered: