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

Impossible to use system nodejs from a container image

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Trivial
    • Resolution: Not A Defect
    • Component/s: nodejs-plugin
    • Labels:
      None
    • Environment:
      Docker LTS deployed in Kubernetes, container-based build only
    • Similar Issues:

      Description

      I am unable to get nodejs-plugin to pickup node installation from https://hub.docker.com/_/node (using version 8-jessie, migrating legacy app). Inside the image the binary is located at /usr/local/bin/node, I am trying to use /usr/local/bin or /usr/local as a tool installation path but it always results in "Couldn’t find any executable in ..." error.

      Ideally I'd like to be able just to omit nodeJSInstallationName so that system default node is used.

        Attachments

          Activity

          Hide
          nfalco Nikolas Falco added a comment -

          Folders you had list are not home of a standard NodeJS. There is no reason to configure a plugin that manage multiple versions of NodeJS indipendently from the platform and contributes the PATH environment variable and than use the NodeJS installed on local syatem. Simply do not use NodeJS plugin step you should get the system PATH in any shell step.

          Show
          nfalco Nikolas Falco added a comment - Folders you had list are not home of a standard NodeJS. There is no reason to configure a plugin that manage multiple versions of NodeJS indipendently from the platform and contributes the PATH environment variable and than use the NodeJS installed on local syatem. Simply do not use NodeJS plugin step you should get the system PATH in any shell step.
          Hide
          lightoze Vladimir Kulev added a comment -

          Plugin step can be still useful for node configuration management.

          Show
          lightoze Vladimir Kulev added a comment - Plugin step can be still useful for node configuration management.
          Hide
          nfalco Nikolas Falco added a comment -

          What di you mean for "node configuration management"?

          Show
          nfalco Nikolas Falco added a comment - What di you mean for "node configuration management"?
          Hide
          lightoze Vladimir Kulev added a comment - - edited

          I mean .npmrc file, the way I meant to use it: 

          nodejs(configId: 'npm-proxy-config') {
            sh 'npm install'
          }

          I eventually managed to achieve the same with configFileProvider([configFile(...)]), but having it like above would be a much cleaner way.

          Show
          lightoze Vladimir Kulev added a comment - - edited I mean .npmrc file, the way I meant to use it:  nodejs(configId: 'npm-proxy-config') { sh 'npm install' } I eventually managed to achieve the same with configFileProvider( [configFile(...)] ), but having it like above would be a much cleaner way.
          Hide
          nfalco Nikolas Falco added a comment - - edited

          Use the configFileProvider is clear way for what you want archieve.

          configFileProvider([configFile(fileId: 'mynpmrc', variable: 'npm_config_userconfig')]) {
              // some block
          }
          

          that is what the build wrapper does. You can use jenkins credential for private repository.

          Or if you use authentication variable in the config file you don't even need to install nodejs plugin.

          configFileProvider([configFile(fileId: 'mynpmrc', targetLocation: '$WORKSPACE\root_of_the_project')]) {
              // some block
          }
          

          NodeJS is specialized to provide an automatic installation regardless of operating system. You can also define a tool specific for that docker image in Jenkins->Manage Jenkins->Global Tool Configuration->Add NodeJS installation and than disable "Install automatically" checkbox. Put there the home folder of the NodeJS. At runtime it verifies if node executable file exists in the ${PATH}/bin/node (depending by the version and operative system). If you do that, it works (I had try locally on my computer). It's a bit useless since the defined tool works only on that docker image and loose the global package install feature.

          If you had test with a valid (for sure not /usr/local/bin or /usr/local) NodeJS home path and does not work than I will spend time for futher investigation on other O.S. different than mine otherwise I will close the issue as "Not a Defect"

          I do not want make tool as optional parameter or define a "System Default" tool because I can not gaurantee nodejs is really installed and this cause confusion (and issue opening) when the same pipeline work on a node but not on other.

          Show
          nfalco Nikolas Falco added a comment - - edited Use the configFileProvider is clear way for what you want archieve. configFileProvider([configFile(fileId: 'mynpmrc', variable: 'npm_config_userconfig')]) { // some block } that is what the build wrapper does. You can use jenkins credential for private repository. Or if you use authentication variable in the config file you don't even need to install nodejs plugin. configFileProvider([configFile(fileId: 'mynpmrc', targetLocation: '$WORKSPACE\root_of_the_project')]) { // some block } NodeJS is specialized to provide an automatic installation regardless of operating system. You can also define a tool specific for that docker image in Jenkins->Manage Jenkins->Global Tool Configuration->Add NodeJS installation and than disable "Install automatically" checkbox. Put there the home folder of the NodeJS. At runtime it verifies if node executable file exists in the ${PATH}/bin/node (depending by the version and operative system). If you do that, it works (I had try locally on my computer). It's a bit useless since the defined tool works only on that docker image and loose the global package install feature. If you had test with a valid (for sure not /usr/local/bin or /usr/local) NodeJS home path and does not work than I will spend time for futher investigation on other O.S. different than mine otherwise I will close the issue as "Not a Defect" I do not want make tool as optional parameter or define a "System Default" tool because I can not gaurantee nodejs is really installed and this cause confusion (and issue opening) when the same pipeline work on a node but not on other.

            People

            • Assignee:
              nfalco Nikolas Falco
              Reporter:
              lightoze Vladimir Kulev
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: