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

Override default NodeJS registry when installing in global mode on Global Tools Configuration page

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Postponed
    • Component/s: nodejs-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.32.3 LTS / NodeJS plugin 1.1.2
    • Similar Issues:

      Description

      Currently the default registry is set to http://registry.nodejs.org for global mode module installation.
      Can you implement a way to override this registry? (We use our corporate NPM registry)

       

      Regards

       

        Attachments

          Activity

          Hide
          nfalco Nikolas Falco added a comment -

          Create a new npm config file (Jenkins -> Manage Jenkins -> Config file) and setup your corporate registry there. An npmrc file is setup to be used in NodeJS step or in the build environment "Provide Node & npm bin/ folder to PATH".

          I know that a detailed description of config file is missing in the jenkins wiki page.

          Show
          nfalco Nikolas Falco added a comment - Create a new npm config file (Jenkins -> Manage Jenkins -> Config file) and setup your corporate registry there. An npmrc file is setup to be used in NodeJS step or in the build environment "Provide Node & npm bin/ folder to PATH". I know that a detailed description of config file is missing in the jenkins wiki page.
          Hide
          lautou Laurent TOURREAU added a comment -

          I reopen the ticket because it doesn't work when specifying "Global npm packages to install" option with "Install from node.js" on NodeJS installations section of Global Tools Configuration page.
          As workaround I have to add --registry argument in "Global npm packages to install" option.

          Show
          lautou Laurent TOURREAU added a comment - I reopen the ticket because it doesn't work when specifying "Global npm packages to install" option with "Install from node.js" on NodeJS installations section of Global Tools Configuration page. As workaround I have to add --registry argument in "Global npm packages to install" option.
          Hide
          nfalco Nikolas Falco added a comment - - edited

          You right, I was miss the "Global Tools Configuration page" part. It's a know limitation because I have not decide if and how handle NPM config file in global.

          Personally I think that typical use case of global installation is install package that 99% does not come from corporate registry like phantom, bower, grunt and so on.
          Instead if you use corporate registry to install global packages as proxy becuase internet than configure jenkins proxy (it is supported).

          As workaround exist we move priority to Normal
          Other workaround is add an environment variable (at node level or as global) like *npm_config_*registry as describe here

          Show
          nfalco Nikolas Falco added a comment - - edited You right, I was miss the "Global Tools Configuration page" part. It's a know limitation because I have not decide if and how handle NPM config file in global. Personally I think that typical use case of global installation is install package that 99% does not come from corporate registry like phantom, bower, grunt and so on. Instead if you use corporate registry to install global packages as proxy becuase internet than configure jenkins proxy (it is supported). As workaround exist we move priority to Normal Other workaround is add an environment variable (at node level or as global) like *npm_config_*registry as describe here
          Hide
          lautou Laurent TOURREAU added a comment -

          I agree with you regarding the global installation mainly concern 3rd party tools like bower, gulp, etc. It's our case.
          But in our company we use a corporate registry to achieve better network performance and avoid external traffic.

          The problem now if I set Jenkins proxy settings, the "No proxy" setting is ignored by "Global Tools Configuration" and I get HTTP 403.
          I tried to set --no-proxy "mycorporaterepo.mycompany.com" without any success.
          I also try --noproxy or --no_proxy option without any positive result.

          As workaround I set no_proxy environment variable beside JENKINS_HOME in my tomcat.conf script -> I can access to the internal repo now when Jenkins settings are enabled.

          The NodeJS plugin should be able to set no_proxy variable to deal with such requested feature.
          I change the priority to Major because to sum up, it involves two workarounds now:

          • set --registry parameter in "Global npm packages to install"
          • set no_proxy environment variable at Jenkins startup -> it could have other side effect on other Jenkins features.
          Show
          lautou Laurent TOURREAU added a comment - I agree with you regarding the global installation mainly concern 3rd party tools like bower, gulp, etc. It's our case. But in our company we use a corporate registry to achieve better network performance and avoid external traffic. The problem now if I set Jenkins proxy settings, the "No proxy" setting is ignored by "Global Tools Configuration" and I get HTTP 403. I tried to set --no-proxy "mycorporaterepo.mycompany.com" without any success. I also try --noproxy or --no_proxy option without any positive result. As workaround I set no_proxy environment variable beside JENKINS_HOME in my tomcat.conf script -> I can access to the internal repo now when Jenkins settings are enabled. The NodeJS plugin should be able to set no_proxy variable to deal with such requested feature. I change the priority to Major because to sum up, it involves two workarounds now: set --registry parameter in "Global npm packages to install" set no_proxy environment variable at Jenkins startup -> it could have other side effect on other Jenkins features.
          Hide
          nfalco Nikolas Falco added a comment - - edited

          Actually registry.nodejs.org is the only actual default registry for global packages.
          The jenkins no proxy value is validated against the default npm registry URL, so if you add npm.registry.org in no proxy Jenkins settings the http_proxy and https_proxy are not set during npm install -g action.

          If I understand right only npm >= 3 support no_proxy, and only as enviroment variable (details here)

          In real it's a little bit complicated becuase some global package could have scope that refer to a different registry:

          @mycorporate:registry=mycorporaterepo.mycompany.com

          I should support npmrc in global package and taking care about all registry and foreach one check against jenkins no proxy and make a mix behavior to support also old version of npm.

          Anyway remember that you could setup registry and no_proxy as global variable prefixed by npm_config_ as described in my previous post. All enviroment variables with that prefix are considered by npm like written in a .npmrc file.

          Show
          nfalco Nikolas Falco added a comment - - edited Actually registry.nodejs.org is the only actual default registry for global packages. The jenkins no proxy value is validated against the default npm registry URL, so if you add npm.registry.org in no proxy Jenkins settings the http_proxy and https_proxy are not set during npm install -g action. If I understand right only npm >= 3 support no_proxy, and only as enviroment variable ( details here ) In real it's a little bit complicated becuase some global package could have scope that refer to a different registry: @mycorporate:registry=mycorporaterepo.mycompany.com I should support npmrc in global package and taking care about all registry and foreach one check against jenkins no proxy and make a mix behavior to support also old version of npm. Anyway remember that you could setup registry and no_proxy as global variable prefixed by npm_config_ as described in my previous post. All enviroment variables with that prefix are considered by npm like written in a .npmrc file.
          Hide
          nfalco Nikolas Falco added a comment -

          In master I've changed the no proxy host management so all no proxy hosts are put in the environment variable NO_PROXY, a list of host comma separated.
          Keep in mind that wild card seems not be supported by npm.

          Show
          nfalco Nikolas Falco added a comment - In master I've changed the no proxy host management so all no proxy hosts are put in the environment variable NO_PROXY, a list of host comma separated. Keep in mind that wild card seems not be supported by npm.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Nikolas Falco
          Path:
          src/main/java/jenkins/plugins/nodejs/NodeJSBuildWrapper.java
          src/main/java/jenkins/plugins/nodejs/tools/NodeJSInstallation.java
          src/main/java/jenkins/plugins/nodejs/tools/NodeJSInstaller.java
          src/main/resources/jenkins/plugins/nodejs/NodeJSBuildWrapper/config.jelly
          src/main/resources/jenkins/plugins/nodejs/tools/NodeJSInstallation/config.jelly
          src/main/resources/jenkins/plugins/nodejs/tools/NodeJSInstallation/config.properties
          src/main/resources/jenkins/plugins/nodejs/tools/NodeJSInstaller/global_it.properties
          http://jenkins-ci.org/commit/nodejs-plugin/b6e03b5053d55afc59da135671fbac35d501451d
          Log:
          JENKINS-42675 Permit to select a npm user config for each NodeJS installation, but when the install should be performed to generate the content of NPMConfig file an instance of build is needed because:

          • provides a non accessible path where place the file (with write permissions)
          • environment variables (of the build) to perform the replace token
          • resolve the credentials
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nikolas Falco Path: src/main/java/jenkins/plugins/nodejs/NodeJSBuildWrapper.java src/main/java/jenkins/plugins/nodejs/tools/NodeJSInstallation.java src/main/java/jenkins/plugins/nodejs/tools/NodeJSInstaller.java src/main/resources/jenkins/plugins/nodejs/NodeJSBuildWrapper/config.jelly src/main/resources/jenkins/plugins/nodejs/tools/NodeJSInstallation/config.jelly src/main/resources/jenkins/plugins/nodejs/tools/NodeJSInstallation/config.properties src/main/resources/jenkins/plugins/nodejs/tools/NodeJSInstaller/global_it.properties http://jenkins-ci.org/commit/nodejs-plugin/b6e03b5053d55afc59da135671fbac35d501451d Log: JENKINS-42675 Permit to select a npm user config for each NodeJS installation, but when the install should be performed to generate the content of NPMConfig file an instance of build is needed because: provides a non accessible path where place the file (with write permissions) environment variables (of the build) to perform the replace token resolve the credentials
          Hide
          nfalco Nikolas Falco added a comment - - edited

          This suggestion could not be implemented because to generate the content of a configured npmrc file an instance of build job is needed for the following reasons:

          • provide a path where place the file
          • environment variables (of the build) to perform the replace token
          • resolve the credentials
            And no one installer has access to the current build job because are not related and could be runned separatly.

          Actually I do not see a way to implements this.

          Show
          nfalco Nikolas Falco added a comment - - edited This suggestion could not be implemented because to generate the content of a configured npmrc file an instance of build job is needed for the following reasons: provide a path where place the file environment variables (of the build) to perform the replace token resolve the credentials And no one installer has access to the current build job because are not related and could be runned separatly. Actually I do not see a way to implements this.

            People

            • Assignee:
              nfalco Nikolas Falco
              Reporter:
              lautou Laurent TOURREAU
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: