Certified Jenkins Engineer

Setting up CI Pipeline

Demo Install Dependencies

Demo: Install Node.js Dependencies in Your Jenkins Pipeline

In this tutorial, we’ll show you how to integrate a Node.js install step into your Jenkins Pipeline, verify your Node.js version, and install project dependencies. By the end, you’ll see how Blue Ocean displays your pipeline stages and where the node_modules folder appears in the workspace.

Prerequisites

Note

Make sure the NodeJS Plugin is installed and configured under Manage JenkinsGlobal Tool Configuration.

Pipeline Configuration

  1. Open your Jenkinsfile.
  2. Configure the Node.js tool and define two stages:
    • VM Node Version: Verifies node and npm versions.
    • Installing Dependencies: Runs npm install --no-audit.
Stage NamePurposeCommand
VM Node VersionCheck Node.js and npm versionsnode -v, npm -v
Installing DependenciesInstall project dependencies with npmnpm install --no-audit
pipeline {
    agent any

    tools {
        nodejs 'nodejs-22-6-0'
    }

    stages {
        stage('VM Node Version') {
            steps {
                sh 'node -v'
                sh 'npm -v'
            }
        }

        stage('Installing Dependencies') {
            steps {
                sh 'npm install --no-audit'
            }
        }
    }
}

Warning

Using --no-audit skips vulnerability checks. Consider running npm audit or integrating a security scanner in your CI/CD pipeline for production workloads.

Run the Pipeline

  1. Commit and push your Jenkinsfile changes.
  2. In Blue Ocean, watch the pipeline execute both stages in sequence.

Sample Output for “Installing Dependencies”

+ npm install --no-audit
added 365 packages in 5s
44 packages are looking for funding
run 'npm fund' for details

Verify the Workspace

After the build completes, navigate to Workspaces in the Jenkins UI. You should see a node_modules directory with all installed dependencies:

The image shows a Jenkins workspace interface displaying a list of node modules in a project directory. The interface includes navigation options like "Dashboard," "Console Output," and "Open Blue Ocean."


Watch Video

Watch video content

Previous
Demo Add Jenkinsfile to Solar System Repo