[JIRA] (JENKINS-60720) Possibility to specify if env variables should be filtered or not in npm config file

12 views
Skip to first unread message

anders@hammar.net (JIRA)

unread,
Jan 10, 2020, 2:35:03 AM1/10/20
to jenkinsc...@googlegroups.com
Anders Hammar created an issue
 
Jenkins / Improvement JENKINS-60720
Possibility to specify if env variables should be filtered or not in npm config file
Issue Type: Improvement Improvement
Assignee: Nikolas Falco
Components: nodejs-plugin
Created: 2020-01-10 07:34
Priority: Major Major
Reporter: Anders Hammar

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:

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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

anders@hammar.net (JIRA)

unread,
Jan 10, 2020, 3:05:01 AM1/10/20
to jenkinsc...@googlegroups.com
Anders Hammar commented on Improvement JENKINS-60720
 
Re: Possibility to specify if env variables should be filtered or not in npm config file

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

anders@hammar.net (JIRA)

unread,
Jan 10, 2020, 3:35:02 AM1/10/20
to jenkinsc...@googlegroups.com

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

anders@hammar.net (JIRA)

unread,
Jan 10, 2020, 3:35:02 AM1/10/20
to jenkinsc...@googlegroups.com
Anders Hammar updated an issue
 
Change By: Anders Hammar
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:


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.

anders@hammar.net (JIRA)

unread,
Jan 10, 2020, 3:36:02 AM1/10/20
to jenkinsc...@googlegroups.com
Anders Hammar closed an issue as Not A Defect
 

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

Change By: Anders Hammar
Status: Open Closed
Assignee: Nikolas Falco
Resolution: Not A Defect

anders@hammar.net (JIRA)

unread,
Jan 10, 2020, 3:57:02 AM1/10/20
to jenkinsc...@googlegroups.com
Anders Hammar edited a comment on Improvement JENKINS-60720
This is handled by the Token Macro plugin and after some investigation there is an (undocumented) way to do this by specifying three four ( 3 4 ) '$' chars. So my example would then be:
{code}
registry=http://nexus.acme.org/repository/npm-group/
//nexus.acme.org/repository/npm-releases/:_authToken=$$$
$ {NPM_TOKEN}
{code}

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.

anders@hammar.net (JIRA)

unread,
Jan 10, 2020, 6:30:02 AM1/10/20
to jenkinsc...@googlegroups.com
Anders Hammar updated an issue
Change By: Anders Hammar
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
Reply all
Reply to author
Forward
0 new messages