Continuous Integration For NPM Project in Ubuntu
Last Updated :
30 Mar, 2023
In this post, we'll see how to make a continuous integration pipeline for an npm project in Jenkins. We will be building, testing, and then finally packaging our npm project in Jenkins. You can refer to the this article to know the basics of docker and Jenkins. All these commands and steps are valid for Ubuntu operating system.
Step 1: Firstly, we need to have Jenkins for that we'll pull the image of Jenkins using the command below.
docker pull jenkins/jenkinsUbuntu
You can get the container id of your image from the docker desktop.
Step 2: Use the below command to start the Jenkins container using the container id.
docker start determined_newton
Step-3: Use the below command to run the Jenkins image.
docker exec -it -u root determined_newton /bin/bash
Step-4: Now you need to run the following commands inside your container.
apt-get update
apt-get install npm
apt-get install zip
These commands are required to update the container and install node js and zip.
For the steps to set up the basic Jenkins environment by using the admin password and creating the admin user id refer to the this article. After creating a user id you need to log in with your credentials.
Step 5: Installing the required plugins required for the npm project in the “Manage Jenkins", under the "Manage plugins" section that is Build Pipeline Plugin and NodeJS.
Step 6: Configure the global configuration for the NodeJS.

First making independent files for build, test, and package then we will integrate all three together thus creating a pipeline.
Pre-Build steps:
Make first build job by clicking on the “New Item” option in the sidebar and giving the name of the item and selecting “Freestyle project” as an npm project.
Build:
Under source code management enter the git repository link with “.git” as an extension as shown below:
Execute shell: npm install
After building we get the output in the console.

Test:
Execute shell: npm install, npm test
After configuration build the test phase.

Package:
Execute shell: npm install, npm run package

Post-build steps: Integration of Build-Test-Package
Build:
Building connection to the test file


Test:
Building connection to the Package file


Package:
Archive the artifact - **/distribution/*.zip
Specifying zip
Now run all the files build, test and package.
Pipeline creation:
Click on the '+' sign on the home screen to build and configure the pipeline.


Pipeline:
Hence Continuous Integration Pipeline for the npm project is made.
Similar Reads
How to Build React App in Jenkins?
Jenkins is a popular tool for Continuous Integration. Using Jenkins, we can externalize the build process for our code. It allows teams to collaborate more efficiently and deliver software in shorter cycles. In this article, we will learn how to build a react app in Jenkins. Steps To Install Jenkins
7 min read
Docker - Docker Container for Node.js
Node.js is an open-source, asynchronous event-driven JavaScript runtime that is used to run JavaScript applications. It is widely used for traditional websites and as API servers. At the same time, a Docker container is an isolated, deployable unit that packages an application along with its depende
12 min read
How to Call 'npm start' though Docker ?
Docker is a powerful tool for creating, deploying, and running applications inside containers. If you have a Node.js application, you might want to run it inside a Docker container to ensure consistency across different environments. This article will guide you on how to call npm start through Docke
2 min read
Node.Js Application Deployment in Kubernetes with Jenkins CI/CD Pipeline
As we know in the modern world we use Continuous Integration and Continuous Deployment for fast and and efficient delivery of our application to the market. Here in this Article, we are deep-diving into how Actually we can deploy Nodejs applications on Kubernetes with the help of Jenkins CI/CD. Prim
9 min read
How to Build Angular Application in jenkins ?
Jenkins is a popular tool for Continuous Integration. Using Jenkins, we can externalize the build process for our code. It allows teams to collaborate more efficiently and deliver software in shorter cycles. In this article, we will learn how to build an angular app in Jenkins. Pre-RequisitesClone t
6 min read
How to Deploy React App on Azure Virtual Machines?
In this article, we will study how we can deploy our existing React web application to Azure VM on Ubuntu Server. We will also see how to use the public IP of the Azure VM to access the React application using Nginx. For this article, you should know about setting up a VM in Azure. We will see how t
5 min read
Deploying NPM Modules in AWS Lambda
AWS Lambda definitely does change the way in which developers build and deploy their applications. it provides a serverless computing environment in which code can be executed in response to specific events without the need to manage the environment. When working with AWS Lambda, especially with Nod
6 min read
How to Create a Dockerfile in Node.js ?
A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. It is something like a shellscript that gathers multiple commands into a single document to fulfill a single task. Prerequisite: Before you can Dockerize any application, you ne
4 min read
Docker Compose for Node.js Applications
Docker Compose is a powerful tool that facilitates managing multi-container Docker applications. While developing Node.js applications, it usually gets to a point where you need to interact with services such as a database, message broker, or cache system. Manually handling these services can be qui
6 min read
Managing Dependencies in Dockerized Applications
Docker uses a daemon service with root privileges to run an application or a Dockerfile in an isolated environment. Dockerfile can have a lot of dependencies in it, and managing those is an important part in creating a docker image to be used by anyone in any environment. In this article, we will le
3 min read