Download & Installation

You can download the latest .hpi and install it from the Manage Plugins menu, or install this plugin directly from the Plugins Update Center.

Main features

Provides NodeJS auto-installer, allowing to create as many NodeJS installations "profiles" as you want. The auto-installer will automatically install a given version of NodeJS, on every jenkins slave where it will be needed

Allows to install globally some npm packages inside each installations, these npm packages will be made available to the PATH

Allows to execute some NodeJS script, under a given NodeJS installation

Usage

After installing the plugin, go to the global jenkins configuration panel (JENKINS_URL/configure or JENKINS_URL/configureTools if using jenkins 2), and add new NodeJS installations.

For every Nodejs installation, you can choose to install some global npm packages. Since 1.2.6 you could force the installation of the 32bit package for the underlying architecture if supported. If the package is not available the build will fail.

Note that you might provide npm package's version (with syntax "package@0.1.2" for instance, or maybe better, "package@~0.1.0") in order to enforcereproductibility of your npm execution environnment (the ~ syntax allows to benefits from bugfixes without taking the risk of a major version upgrade) See below:

Now, go to a job configuration screen, you will have 2 new items :

On the "Build environnment" section, you will be able to pick one of the NodeJS installations to provide its bin/ folder to the PATH. This way, during shell build scripts, you will have some npm executables available to the command line (like bower or grunt) See below:

On the "Build" section, you will be able to add a "Execute NodeJS script" build step This way, you will be able to fill a textarea with the script content you want to execute. Note that you will have to select a NodeJS runtime you previously installed, to specify the NodeJS version you want to use during your NodeJS script execution.

You can customise any NPM settings you need creating a NPM config file where you can also setup multiple npm registry (scoped or public) and select for each one stored credential (only user/password supported type) as follow: and than select the config file to use for each configured build step

Pipeline

The current supported DSL steps are:

nodejs (as buildwrapper)

tools

In a Declarative pipeline you can add any configured NodeJS tool to your job, and it will enhance the PATH variable with the selected NodeJS installation folder, instead in scripted pipeline you have to do it manually.

Known limitations / issues

NodeJS version 1.0 has adapted its code to the most recent Jenkins API (1.6xx). If also EnvInject is installed you will fall in JENKINS-26583 that corrupts setup of the nodejs installation bin folder into PATH environment. In this case consider if update or not or use an own build fromthis branch untill the JENKINS-26583 will not be fixed.

If you update from NodeJS 0.2.2 or earlier to newer version materializes a data migration. This data migration is transparent to the users but you can not back to 0.2.2 without lost global configuration tools and job build step configuration.

NodeJS versions prior to 0.9.0 won't be available at the moment (directory structure was not the same as today on distribution site). This might be handled in the future (this is exposed as PathResolver implementation) : don't hesitate to provide new implementations for previous versions and submit a PR on github.

0.2.2 (December, 12th, 2016)

Bugfixes

JENKINS-30380 : Downloads of NodeJS binaries are now in https (aheritier)

0.2.1 (February, 10th, 2014)

Bugfixes

JENKINS-21726 : Fix path separator issue when master & slave OS are not the same (kudos to ljohnston)

Adding node executable at the beginning (instead of end) of the PATH (kudos to trecloux)

0.2 (August, 24th, 2013)

Improvements

Provided NodeJS Auto-installers based on available NodeJS versions on nodejs.org Auto-installer will automatically install NodeJS for target node's OS/CPU type (only linux x86/64 supported ATM) You will be able to define global npm packages installed during the NodeJS installation.

Added a new "Build environnment" checkbox allowing to provide a specific NodeJS installation to the PATH This way, you will be able to execute npm packages, such as grunt or bower, in your shell scripts

13 Comments

There is a compatibility problem with simultaneous use of MySQL Job Database Plugin (0.1.0) and NodeJS Plugin (0.2.1) in the "Build Environment" definition of a Jenkins job.

The environment, where job runs, is a Jenkins master (core version:1.565) on Ubuntu 12.04 with a MySQL installation (5.5.3) and NodeJS installation is 0.10.x (I also used a 0.11.x).

Below there is the log of the build that fails for a "bash: mysql: command not found" error. If Jenkins doesn't find a NodeJS installation, it tries to perform a NodeJS installation and then uses MySQL Job Database plugin to create a mysql database. The issue could be about the path that MySQL Job Database uses to run bash commands, maybe it could be modified by NodeJS Plugin before. Obviously, without the use of NodeJS plugin, MySQL Job Database Plugin works correctly. What does NodeJS Plugin do when it tries to install a specific NodeJS?

Looking for your feedback, thank you in advance,

Silvio

Building on master in workspace /var/lib/jenkins/jobs/Testmysql-clone/workspace

it's not possible use the proxy defined in manage file during installation of pre-installed packages because managed files are wired to the build job and not to Jenkins instance. For example is not possible retrieve managed file defined in a Folder (kind of Jenkins project).

If you would use an HTTP proxy define the http proxy in the Manage Jenkins page (see JENKINS-29266).