Allows pipelines to configure an NPM environment via managed npmrc files
This plugin provides integration with Pipeline by configuring an NPM environment to use within a pipeline job by calling
sh npm or
bat npm. This is accomplished by adding an
npmrc as a custom config file to be centrally managed by Jenkins. This is useful for managing registries, authorizations, and any other npm settings that one would like to manage via Jenkins outside of the pipeline itself.
This plugin works both with and without Docker containers as build steps.
Via Config File Management, Manage Jenkins -> Managed Files, add an npmrc entry specifying the id that will be used in the pipeline configuration.
In the above example, 'my-custom-npmrc' is a config file that had been added as a custom, Managed File. Underneath, the custom
npmrc is being copied to the workspace where it will serve as a local override during the build. Nominally, npm would have a command line mechanism for specifying the npmrc, but for now the best choice to force an override is to place the
npmrc in the workspace where it will be prioritized over the home and global
Here is another example using Docker and Pipeline Model Definition Plugin. When using the Docker based approach, the npmrc is installed to the user home location.
- When not using a Docker based build, NPM must be installed on the build executor.
- When not using a Docker based build, any local npmrc to the workspace will be replaced by this plugin.
- 0.9.0 -- Initial Release
- 0.9.1 -- Removed wrapper script since there is no useful way to override the npmrc on the command line. This simplifies things a fair bit in terms of the code.