{"id":22280927,"url":"https://github.com/jenkinsci/nodejs-plugin","last_synced_at":"2025-04-04T18:07:06.247Z","repository":{"id":636368,"uuid":"1163661","full_name":"jenkinsci/nodejs-plugin","owner":"jenkinsci","description":"Jenkins nodejs plugin","archived":false,"fork":false,"pushed_at":"2025-03-24T20:23:05.000Z","size":1055,"stargazers_count":69,"open_issues_count":2,"forks_count":81,"subscribers_count":96,"default_branch":"master","last_synced_at":"2025-03-28T17:10:25.413Z","etag":null,"topics":["jenkins-plugin","jenkins-tools","nodejs","npm"],"latest_commit_sha":null,"homepage":"https://plugins.jenkins.io/nodejs/","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jenkinsci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.header","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-12-13T05:45:55.000Z","updated_at":"2025-02-20T17:30:07.000Z","dependencies_parsed_at":"2023-07-05T15:16:43.453Z","dependency_job_id":"0a75f68c-bce4-4ad7-9796-a226547857f6","html_url":"https://github.com/jenkinsci/nodejs-plugin","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fnodejs-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fnodejs-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fnodejs-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fnodejs-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenkinsci","download_url":"https://codeload.github.com/jenkinsci/nodejs-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226213,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jenkins-plugin","jenkins-tools","nodejs","npm"],"created_at":"2024-12-03T16:10:25.542Z","updated_at":"2025-04-04T18:07:06.226Z","avatar_url":"https://github.com/jenkinsci.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NodeJS Plugin for Jenkins\n\n\n[![Jenkins Plugin](https://img.shields.io/jenkins/plugin/v/nodejs.svg)](https://plugins.jenkins.io/nodejs)\n[![GitHub release](https://img.shields.io/github/release/jenkinsci/nodejs-plugin.svg?label=release)](https://github.com/jenkinsci/nodejs-plugin/releases/latest)\n[![Jenkins Plugin Installs](https://img.shields.io/jenkins/plugin/i/nodejs.svg?color=blue)](https://plugins.jenkins.io/nodejs)\n\nProvides Jenkins integration for NodeJS \u0026 npm packages.\n\n## Download \u0026 Installation\n\nYou can download the [latest\n.hpi](http://updates.jenkins-ci.org/latest/nodejs.hpi) and install it\nfrom the Manage Plugins menu, or install this plugin directly from the\nPlugins Update Center.\n\n## Main features\n\n-   Provides NodeJS auto-installer, allowing to create as many NodeJS\n    installations \"profiles\" as you want.  \n    The auto-installer will automatically install a given version of\n    NodeJS, on every jenkins agent where it will be needed\n-   Allows to install globally some npm packages inside each\n    installations, these npm packages will be made available to the PATH\n-   Allows to execute some NodeJS script, under a given NodeJS\n    installation\n-   Allows use custom NPM user configuration file defined with\n    config-file-provider plugin to setup custom NPM settings\n-   Add a lightweight support to DSL pipeline\n-   Force 32bit architecture\n-   Relocate npm cache folder using pre defined strategies\n-   Allow use of a mirror repo for downloading and installing NodeJS.\n-   Cache NodeJS archives per architecture to speedup installations on\n    ephemeral Jenkins slaves.\n\n## Usage\n\n1.  After installing the plugin, go to the global jenkins configuration\n    panel (JENKINS\\_URL/configure or JENKINS\\_URL/configureTools if\n    using jenkins 2),  \n    and add new NodeJS installations.\n    - If you wish to install NodeJS from a nodejs.org mirror, \n    select the \"Install from nodejs.org mirror\" option, where you can \n    then enter a mirror URL and then install NodeJS just like you would \n    from nodejs.org.\n2.  For every Nodejs installation, you can choose to install some global\n    npm packages.  \n    Since 1.2.6 you could force the installation of the 32bit package\n    for the underlying architecture if supported. If the package is not\n    available the build will fail.\n\n    *Note that you might provide npm package's version (with syntax\n    \"package@0.1.2\" for instance, or maybe better, \"package@\\~0.1.0\") in\n    order to enforce*  \n    *reproductibility of your npm execution environment (the \\~ syntax\n    allows to benefits from bugfixes without taking the risk of a major\n    version upgrade)*  \n    See below:  \n    ![](docs/images/nodejs_tools_configuration.png)\n\n3.  Now, go to a job configuration screen, you will have 2 new items :\n    -   On the \"Build environment\" section, you will be able to pick\n        one of the NodeJS installations to provide its bin/ folder to\n        the PATH.  \n        This way, during shell build scripts, you will have some npm\n        executables available to the command line (like bower or\n        grunt)  \n        See below:  \n        ![](docs/images/nodejs_npm_to_path.png)\n    -   On the \"Build\" section, you will be able to add a \"Execute\n        NodeJS script\" build step  \n        ![](docs/images/nodejs_buildstep_menu.png)  \n        This way, you will be able to fill a textarea with the script\n        content you want to execute.  \n        Note that you will have to select a NodeJS runtime you\n        previously installed, to specify the NodeJS version you want to\n        use  \n        during your NodeJS script execution.  \n        ![](docs/images/nodejs_buildstep_script.png)\n4.  You can customise any [NPM\n    settings](https://docs.npmjs.com/misc/config#config-settings) you\n    need creating a NPM config file where you can also setup multiple\n    npm registry (scoped or public)  \n    and select for each one stored credential (only user/password\n    supported type) as follow:  \n    ![](docs/images/nodejs_npm_configfile.png)\n    \n    and then select the config file to use for each configured build\n    step\n    \n    ![](docs/images/nodejs_choose_configfile.png)\n    \n    You can also choose if enable or not the support for npm 9+ version.\n5.  You would relocate the npm cache folder to swipe out it when a job\n    is removed or workspace folder is deleted. There are three default\n    strategy:\n    -   per node, that is the default NPM behaviour. All download package\n        are placed in the \\~/.npm on Unix system or\n        %APP\\_DATA%\\\\npm-cache on Windows system;\n    -   per executor, where each executor has an own NPM cache folder\n        placed in \\~/npm-cache/$executorNumber;\n    -   per job, placed in the workspace folder under\n        $WORKSPACE/npm-cache. This cache will be swipe out together the\n        workspace and will be removed when the job is deleted.\n\n## Configure cache\n\nEach time an executor request a new NodeJS installation after download\nthe NodeJS archive it is stored on master node in JENKINS_HOME/caches/nodejs.\nThis is done to speed up the installation on a Jenkins slaves (for example\non ephemeral slaves in kubernetes) and reduce internet traffic.\n\nThis functionality can be turn off adding a JVM property in java options:\n\n`JENKINS_JAVA_OPTIONS=\"[...] -Djenkins.plugins.nodejs.tools.NodeJSInstaller.cache.disable=true\"`\n\n## Pipeline\n\nThe current supported DSL steps are:\n\n-   nodejs (as buildwrapper)\n-   tools\n\nIn a Declarative pipeline you can add any configured NodeJS tool to your\njob, and it will enhance  \nthe PATH variable with the selected NodeJS installation folder, instead\nin scripted pipeline you have to do it manually.\n\n***Example of use tools in Jenkinsfile (Scripted Pipeline)***\n\n``` groovy\nnode {\n    env.NODEJS_HOME = \"${tool 'Node 6.x'}\"\n    // on linux / mac\n    env.PATH=\"${env.NODEJS_HOME}/bin:${env.PATH}\"\n    // on windows\n    env.PATH=\"${env.NODEJS_HOME};${env.PATH}\"\n    sh 'npm --version'\n}\n```\n\nThis example show the use of **buildwrapper**, where enhanced PATH will\nbe available only inside the brace block\n\n***Example of the use of buildwrapper Jenkinsfile (Declarative\nPipeline)***\n\n``` groovy\npipeline {\n    agent any\n\n    stages {\n        stage('Build') {\n            steps {\n                nodejs(nodeJSInstallationName: 'Node 6.x', configId: '\u003cconfig-file-provider-id\u003e') {\n                    sh 'npm config ls'\n                }\n            }\n        }\n    }\n}\n```\n\n## Configure plugin via Groovy script\n\nEither automatically upon [Jenkins post-initialization](https://www.jenkins.io/doc/book/managing/groovy-hook-scripts/#post-initialization-script-init-hook)\nor through [Jenkins script console](https://www.jenkins.io/doc/book/managing/script-console/), example:\n\n```groovy\n#!/usr/bin/env groovy\nimport hudson.tools.InstallSourceProperty\nimport jenkins.model.Jenkins\nimport jenkins.plugins.nodejs.tools.NodeJSInstallation\nimport jenkins.plugins.nodejs.tools.NodeJSInstaller\nimport static jenkins.plugins.nodejs.tools.NodeJSInstaller.DEFAULT_NPM_PACKAGES_REFRESH_HOURS\n\nfinal versions = [\n        'NodeJS 8.x': '8.16.1'\n]\n\nJenkins.instance.getDescriptor(NodeJSInstallation).with {\n    installations = versions.collect {\n        new NodeJSInstallation(it.key, null, [\n                new InstallSourceProperty([\n                        new NodeJSInstaller(it.value, null, DEFAULT_NPM_PACKAGES_REFRESH_HOURS)\n                ])\n        ])\n    }  as NodeJSInstallation[]\n}\n```\n\n## Known limitations / issues\n\nNodeJS version 1.0 has adapted its code to the most recent Jenkins API\n(1.6xx). If also EnvInject is installed you will fall in\n[JENKINS-26583](https://issues.jenkins-ci.org/browse/JENKINS-26583)  \nthat corrupts setup of the nodejs installation bin folder into PATH\nenvironment. In this case consider if update or not or use an own build\nfrom  \n[this\nbranch](https://github.com/jenkinsci/nodejs-plugin/tree/workaround-26583)\nuntil the JENKINS-26583 will not be fixed.\n\n-   If you update from NodeJS 0.2.2 or earlier to newer version\n    materializes a data migration. This data migration is transparent to\n    the users but  \n    you can not back to 0.2.2 without lost global configuration tools\n    and job build step configuration.\n-   NodeJS versions prior to 0.9.0 won't be available at the moment\n    (directory structure was not the same as today on distribution\n    site).  \n    This might be handled in the future (this is exposed as\n    [PathResolver\n    implementation](https://github.com/jenkinsci/nodejs-plugin/blob/master/src/main/java/jenkins/plugins/nodejs/tools/pathresolvers/LatestInstallerPathResolver.java))\n    :  \n    don't hesitate to provide new implementations for previous versions\n    and submit a PR on github.\n-   Supported architecture are:\n    -   Windows 32/64 bit\n    -   Linux 32/64 bit\n    -   OSX (intel) 64 bit\n    -   Arm 6l/7l/64\n    -   SunOS\n    -   AIX\n\n## Releases Notes\n\n**Please refer to [github repository page](https://github.com/jenkinsci/nodejs-plugin/releases)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkinsci%2Fnodejs-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenkinsci%2Fnodejs-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkinsci%2Fnodejs-plugin/lists"}