×
Find plugins

NodeJS1.2.4Minimum Jenkins requirement: 1.651.3ID: nodejs

Installs: 15697
Last released: 16 days ago
Maintainers
Cliffano Subagio
Frédéric Camblor
Nikolas Falco
Provides Jenkins integration for NodeJS & npm packages.

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
  • Allows use custom NPM user configuration file defined with config-file-provider plugin to setup custom NPM settings
  • Add a lightweight support to DSL pipeline

Usage

  1. 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.
  2. For every Nodejs installation, you can choose to install some global npm packages.
    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 enforce
    reproductibility of your npm execution environnment (the ~ syntax allows to benefits from bugfixes without taking the risk of a major version upgrade)
    See below:
  3. 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.
  4. 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 currect supported DSL steps are:

  • nodejs buildwrapper
  • tools

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

Jenkinsfile (Scripted Pipeline)
node {
	env.NODEJS_HOME = "${tool 'Node 6.x'}"
	env.PATH="${env.NODEJS_HOME}:${env.PATH}" // on windows node use ;
	sh 'npm --version'
}

This example show the use of wrapper, where enhanced PATH will be available only inside the brace block

Jenkinsfile (Declarative Pipeline)
pipeline {
    agent any
    stages {
        stage('Example') {
            steps {
                nodejs(nodeJSInstallationName: 'Node 6.x', configId: '<config-file-provider-id>') {
                    sh 'npm config ls'
                }
            }
        }
    }
}

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 from
this 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.
  • Supported architecture are:
    • Windows 32/64 bit
    • Linux 32/64 bit
    • OSX (intel) 64 bit
    • Arm 6l/7l/64

Releases

1.2.4 (Sep, 6th, 2017)

Improvements

  • Remove JENKINS-14807 patch because released in Jenkins 2.71 and in 2.60.3 LTS (nfalco79)

1.2.3 (Jul, 29th, 2017)

Improvements

  • JENKINS-45840 : Verify if the NodeJS executable exists before continue with the build step to improve problem determination (nfalco79)
  • Set configId as optional parameter (nfalco79)

1.2.2 (May, 22th, 2017)

Improvements

  • JENKINS-42262 : Supports the new config-file-provider APIs so it can provides the correct content of the npm config file (nfalco79)

Bugfixes

1.2.1 (April, 23th, 2017)

Bugfixes

1.2.0 (March, 31th, 2017)

Improvements

  • JENKINS-43102 : Add support for ARM CPUs (armv7l, armv6l, arm64) (nfalco79)

1.1.3 (March, 15th, 2017)

Bugfixes

  • JENKINS-42775 : NodeJS Plugin - Unresolvable nodeJS installer for version in Windows i386 (nfalco79)

1.1.2 (February, 22th, 2017)

Bugfixes

  • JENKINS-42232 : Node executable is not begin initialised on slave node (nfalco79)

1.1.1 (February, 20th, 2017)

Bugfixes

  • JENKINS-41947 : PATH value is being overwritten in declarative pipeline syntax (nfalco79)
  • JENKINS-29266 : Install global package don't use default proxy (nfalco79)

1.1.0 (February, 13th, 2017)

Improvements

  • JENKINS-40624 : nodejs installer not compatible with declarative pipeline definition (nfalco79 to imod)

Bugfixes

  • Add some test cases
  • JENKINS-41876 : Not respecting configuration in regards of global modules (nfalco79)

1.0.1 (February, 3rd, 2017)

Bugfixes

  • JENKINS-41535 : NodeJS installation configuration is not persisted to file (nfalco79)

1.0 (January, 27th, 2017)

Improvements

  • JENKINS-35182 : Support credential plugin to handle publish (nfalco79)
  • JENKINS-40364 : Support npm configuration file (nfalco79)
  • JENKINS-26828 : Add support for installing the NodeJS windows msi (nfalco79 to icoulter)

Bugfixes

  • JENKINS-21953 : NodeJs plugin doesn't work on windows based Jenkins machine (nfalco79)
  • JENKINS-22102 : NodeJS plugin does not remember the saved "NodeJS Installation" (nfalco79 to unilama)

0.2.2 (December, 12th, 2016)

Bugfixes

  • JENKINS-27170 : "Provide Node & npm bin/ folder to PATH" not working for "npm install" (ndeloof)
  • 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.
  • Updated "Execute NodeJS script" build step, to allow selection of a 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

0.1 (August, 13th, 2010)

Improvements

  • Provided new build step : "Execute NodeJS script"
ArchivesGet past versions
Labels
This plugin has no labels