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

Possibility to specify if env variables should be filtered or not in npm config file

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not A Defect
    • Component/s: nodejs-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.190.3 (on RHEL7 with openJDK 1.8.0)
      Token Macro Plugin v2.10
      Config FIle Provider Plugin v3.6.2
      NodeJS Plugin 1.3.4
    • Similar Issues:

      Description

      In a npm configuration file any environment variable (specified by $VARIABLE_NAME or ${VARIABLE_NAME}) is being filtered/replaced by the env varibale value. If the filtering process can't find the env varibale an error message is logged in the build console.

      However, in some cases it would be desirable to keep the "${VARIABLE_NAME}" string in the used npm config file so that npm itself replaces this. One scenario is for authentication, like this:

      registry=http://nexus.acme.org/repository/npm-group/
      //nexus.acme.org/repository/npm-releases/:_authToken=${NPM_TOKEN}
      

      In this case, for security reasons, you don't want the env variable to be expanded/filtered during the copying of the config file but rather have npm fetching the env variable value during the "npm publish" execution.

        Attachments

          Activity

          Hide
          ahammar Anders Hammar added a comment -

          Seems as this is controlled by the used functionality in config-file-provider-plugin, which always expands (not way to turn off).

          Show
          ahammar Anders Hammar added a comment - Seems as this is controlled by the used functionality in config-file-provider-plugin, which always expands (not way to turn off).
          Hide
          ahammar Anders Hammar added a comment - - edited

          This is handled by the Token Macro plugin and after some investigation there is an (undocumented) way to do this by specifying four (4) '$' chars. So my example would then be:

          registry=http://nexus.acme.org/repository/npm-group/
          //nexus.acme.org/repository/npm-releases/:_authToken=$$$${NPM_TOKEN}
          

          Checking the token macro code it looks like it should be enough with two '$' chars but I can't get that to work with token-macro-plugin v2.10.

          Show
          ahammar Anders Hammar added a comment - - edited This is handled by the Token Macro plugin and after some investigation there is an (undocumented) way to do this by specifying four (4) '$' chars. So my example would then be: registry=http: //nexus.acme.org/repository/npm-group/ //nexus.acme.org/repository/npm-releases/:_authToken=$$$${NPM_TOKEN} Checking the token macro code it looks like it should be enough with two '$' chars but I can't get that to work with token-macro-plugin v2.10.
          Hide
          ahammar Anders Hammar added a comment -

          Solution exists in Token Macro plugin, se above. Closing.

          Show
          ahammar Anders Hammar added a comment - Solution exists in Token Macro plugin, se above. Closing.

            People

            • Assignee:
              Unassigned
              Reporter:
              ahammar Anders Hammar
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: