Problem when using Jenkins NodeJs pipeline plugin

1,213 views
Skip to first unread message

John Doe

unread,
Jul 8, 2017, 4:49:24 AM7/8/17
to Jenkins Users
Hey,

I'm trying to get nodejs plugin working in pipeline, here is example code:
pipeline {
agent any
environment {
TESTGLOBALVARIABLE = 'TEST'
}
tools {
nodejs '7.7.3'
}


jenkins gives me this error:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 7: Invalid tool type "nodejs". Valid tool types: [ant, hudson.tasks.Ant$AntInstallation, org.jenkinsci.plugins.docker.commons.tools.DockerTool, git, hudson.plugins.git.GitTool, go, org.jenkinsci.plugins.golang.GolangInstallation, gradle, hudson.plugins.gradle.GradleInstallation, jdk, hudson.model.JDK, jgit, org.jenkinsci.plugins.gitclient.JGitTool, jgitapache, org.jenkinsci.plugins.gitclient.JGitApacheTool, hudson.plugins.msbuild.MsBuildInstallation, org.jenkinsci.plugins.MsTestInstallation, maven, hudson.tasks.Maven$MavenInstallation, jenkins.plugins.nodejs.tools.NodeJSInstallation, org.jenkinsci.plugins.vs_code_metrics.VsCodeMetricsInstallation] @ line 7, column 9.
           nodejs '7.7.3'
           ^

According to stacktrace nodejs is not recognized and output suggests me to use jenkins.plugins.nodejs.tools.NodeJSInstallation instead, so here is new attempt:

pipeline {
agent any
environment {
TESTGLOBALVARIABLE = 'TEST'
}
tools {
jenkins.plugins.nodejs.tools.NodeJSInstallation '7.7.3'
}

gives me this:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 7: unexpected token: 7.7.3 @ line 7, column 57.
   dejs.tools.NodeJSInstallation '7.7.3'
                                 ^


Any idea how to get this plugin working in pipeline mode ?

Thank you for any help or suggestions!

Frits van der Holst

unread,
Oct 5, 2017, 2:51:57 PM10/5/17
to Jenkins Users
I ran into a similar problem using an other external tool. According to the documentation the Tools keyword/step only works for gradle, jvm and maven.
So I wanted to run an external groovy script via the Groovy  tool installer/plugin.
I arrived at this solution:

    environment {
        GROOVY_HOME
= tool name: 'Groovy-2.4.9', type: 'hudson.plugins.groovy.GroovyInstallation'
   
}
    stages
{
        stage
('Run Groovy') {
            steps
{
                bat
"${groovy_home}/bin/groovy <script.name>"
           
}
       
}
   
}
Enter code here...

I did let the Snippet generator generate this
tool name: 'Groovy-2.4.9', type: 'hudson.plugins.groovy.GroovyInstallation'
Enter code here...

Hope this helps.

Frits
Reply all
Reply to author
Forward
0 new messages