Skip to main content

Command Palette

Search for a command to run...

Node app Deployment using Jenkins Agent

Updated
2 min read
Node app Deployment using Jenkins Agent
R

Passionate ORACLE DATABASE ADMINISTRATOR | DevOps Enthusiast with a strong background in cloud architecture and solutions engineering.

First, we will setup Jenkins Agent

To setup an agent, the Master and Agent nodes must connected using SSH.

We need to add the Master node's public key into the Agent node's authorized keys.

On Master node...

go to /home/ubuntu/.ssh

select .pub key

copy it into Agent's node /home/ubuntu/.ssh/authorized_keys

Go to Jenkins console...

Go to Manage Jenkins/Nodes

Add New Node

Create Node

Do settings as below...

How to add Jenkins Credentials...

Go to Manage Jenkins/ Credentials

Provide the Master node's Private key

Currently showing Agent is offline

Try to launch agent...

Authentication is successful but gives java error

Need to install Java on Agent Node

Make sure the Master & Agent node's Java is of same version

After installing Java on the Agent instance, the Agent -node started working fine

Let's start with Node to-do App Deployment...

Copy code from the below Github repository

https://github.com/rushikesh-rawool10/node-todo-cicd.git

Mention the Agent name as below

pipeline {
    agent {label 'Dev-Agent'}

Before deploying your code make sure of the following points:

  1. Docker and docker-compose should be installed on your machine.

  2. Your Jenkins user should be added to the docker group.

  3. port 8000 (the port on which app will run)should be open from the ec2 instance.

For a detailed explanation of Jenkins declarative pipeline, the webhook trigger, and Jenkins deployment, check another blog on below link:

Jenkins Declarative Pipeline

Running on node Dev-Agent successfully...

Using webhook trigger, Jenkins-Agent, and Jenkins automatic deployment, Our Node todo app is running fine...!