Continuous Integration and deployment of Angular 2+ application using Jenkins on AWS EC2

Install Jenkins on AWS EC2

Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems. As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project.


EC2 Instance

Security Group with Port 8080 open for internet

Java v1.8.x

Install Java

We will be using open java for our demo, Get the latest version from

#yum install java-1.8*

yum -y install java-1.8.0-openjdk

#Confirm Java Version and set the java home

java -version

find /usr/lib/jvm/java-1.8* | head -n 3


export JAVA_HOME


# To set it permanently update your .bash_profile

vi ~/.bash_profile

The output should be something like this,

[root@~]# java -version

openjdk version “1.8.0_151”

OpenJDK Runtime Environment (build 1.8.0_151-b12)

OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

Install Jenkins

We can install jenkins using the rpm or by setting up the repo. We will set up the repo so that we can update it easily in the future.

Get the latest version of jenkins from and install

yum -y install wget

sudo wget -O /etc/yum.repos.d/jenkins.repo

sudo rpm — import

yum -y install jenkins

Start Jenkins

# Start jenkins service

service jenkins start

# Setup Jenkins to start at boot,

chkconfig jenkins on

Accessing Jenkins

By default jenkins runs at port 8080, You can access jenkins at


Configure Jenkins

The default Username is admin

Grab the default password

Password Location:/var/lib/jenkins/secrets/initialAdminPassword using cat command

Skip Plugin Installation; We can do it later

Change admin password

Admin > Configure > Password

Configure java path

Manage Jenkins > Global Tool Configuration > JDK

Global Configuration Tool — JDK

Test Jenkins Jobs

Create “new item”

Enter an item name — AngularProject

Chose Freestyle project

Under the Build section Execute shell: echo “Welcome to Jenkins Demo”

Save your job

Build job

Check “console output”

Configure Git plugin on Jenkins

Git is one of the most popular tools for version control system. you can pull code from git repositories using jenkins if you use github plugin.


Jenkins server

Install Git on Jenkins server

Install git packages on jenkins server

yum install git -y

Setup Git on jenkins console

Install git plugin without restart

Manage Jenkins > Jenkins Plugins > available > github

Configure git path

Manage Jenkins > Global Tool Configuration > git

Global Tool Configuration — Git

Step 1 — Configure Yum Repository

First of all, we need to enable node.js yum repository in our system provided by the Node.js official website. You also need development tools to build native add-ons to be installed on your system.

For Latest Release-

sudo yum install -y gcc-c++ make

curl -sL | sudo -E bash -

For Stable Release-

sudo yum install -y gcc-c++ make

curl -sL | sudo -E bash -

Step 2 — Install Node.js on Amazon Linux

After adding a yum repository in your system let’s install the Node.js package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.

sudo yum install -y nodejs

sudo npm install pm2 -g

Setup NodeJS Plugin on jenkins console

Install NodeJS plugin without restart

Manage Jenkins > Jenkins Plugins > available > NodeJs Plugin

Configure Node JS installations

Manage Jenkins > Global Tool Configuration > NodeJs Installations

Global Tool Configuration- Node JS Installation

Jenkin Jobs

Create a Free style project in Jenkins

Configure the Source Code management

Configure Project — SCM

Add webhook in github project’s setting..

- Payload URL — http:<EC2 instance IP: 8080>/github-webhook/

- Content-Type -application/json

Select the build trigger in Jenkins — Github hook trigger for GITScm Polling

In Build Section

Configure Project — Build Section

we can further configure post build for test and deploy build on server container.