Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-66720

Set NODE_HOME variable when the nodejs tool is used

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: nodejs-plugin
    • Labels:
      None
    • Environment:
      Jenkins LTS: 2.303.1
      NodeJS Plugin: 1.4.0
    • Similar Issues:

      Description

      When the nodejs tool is installed by using the tools block then:

      • the NODEJS_HOME environment variable is set
      • the PATH environment variable is expanded (inject path to the Node.js directory which keeps binaries)

      Unfortunately, the NODEJS_HOME environment variable is not a standard. Many people use the NODE_HOME environment variable instead (see Node.js installation configuration on w3big.com). We could add some workarounds like

      pipeline {
          agent any
          stages {
              stage('Build') {
                  steps {
                      nodejs(nodeJSInstallationName: 'Node 6.x', configId: '<config-file-provider-id>') {
                          withEnv(["NODE_HOME=${env.NODEJS_HOME}"]) {
                            sh 'buildScriptDevelopedByOtherPeople.sh'
                          }
                      }
                  }
              }
          }
      }
      

      but they are very messy. It would be great if both variables could be set. We need some changes in the NodeJSInstallation (extend) and NodeJSConstants (add new constant) classes. There is no need to add the PATH+NODE_HOME environment variable because the PATH+NODEJS_HOME environment variable handles the injection to the PATH environment variable correctly.

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            Assignee:
            nfalco Nikolas Falco
            Reporter:
            agabrys Adam Gabryś
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: