Posted in Cloud Computing

Configure Continuous Deployment And Continuous Integration via Jenkins

Continuous Deployment And Continuous Integration via Jenkins – If we consider a developer’s job, it can be observed that they perform monotonous tasks regularly. Thus, you can imagine how boring their life is. Luckily, due to the great development in science and technology, today (when strives have been made to step into the artificial intelligence age), computers are ideal for performing complex or boring chores.

The two internal elements of development testing and deployment offer an ideal solution when they are appropriately blended with some intelligent automation. The outcomes of the mixture are commonly known as CI, Continuous Integration and CD, Continuous Deployment.

You can also configure some automation to make your monotonous job less tedious. This way you will be able to better concentrate on coding and leave the other tasks to computer.

Before beginning, ensure that the note.js and Git is installed on your system. Without any further ado, let’s ponder into the configuration process and understand how the setup can be established.

  • Step by step process to create, test and deploy a simple application.


1.) Let’s begin with GitHub

  1. a) First login into your account (or if you don’t have any account create a GitHub account),
  2. b) Create a new repository. Save it as “Hi-Jenkins” and add the below mentioned description to it –

“This is a sample application, which is created to test Jenkins.”

  1. c) Make the following tweaks –
  • Set the repository settings as “Public”.
  • Check the button corresponding to “Initialize this repository with README”.
  • Navigate to the “Add.Gitignore” drop-down list and select the option – “Node”.
  • Your repository will be ready after clicking on the “Create repository”

GIT Repository

  1. d) Clone your new repository to your local system and access it.

git clone<you>/hi-jenkins.git

cd hi-jenkins

  1. e) The final structure of your application will look like –

├── .gitignore

├── app.js

├── package.json


├── script

│   ├── deploy

│   └── test

└── test

└── test.js

GIT Repository and Jenkins

2.) Let’s create the Node.js application

a) Create a file “package.json”, it will be like –

Code Snippet:


“name”: “hi-jenkins”,

“description”: “hi jenkins test app”,

“version”: “0.0.1”,

“private”: true,

“dependencies”: {

“express”: “3.12.0”


“devDependencies”: {

“mocha”: “1.20.1”,

“supertest”: “0.13.0”



In the aforementioned piece of code, the “express” is added under the “dependencies” that will facilitate one to create their Node.js application. The “mocha” and “supertest” are added under “devDependencies”, and this will help write your tests.

b) Now, install your application dependencies by executing the following command.


Command:      npm install


c) After doing so, create a file and save it as “app.js” and insert the below mentioned chunk of code to it.


Code Snippet:


// express lib that is defined under package.json is imported

var express = require(‘express’);


// here express function is used for creating a new application

var app = express();


//app will respond to all the requests by hitting to the website root with “Hello”

app.get(‘/’, function (req, res) {



app.listen(process.env.PORT || 5000);


//to make your app available to another Node.js modules

module.exports = app;


d) Finally, the app is ready to be executed. Run it with the following command.


Command:      Node app.js


e) Access any browser and go to the address “http://localhost:5000/”. It will display “Hello” on a plain web page.


  1. Let’s test the created application

a) First, create a new folder and save it as “test”, under this folder create a new file and save it as “test.js”. Now, open the file and add the following lines of code in it –


Code Snippet:

var request = require(‘supertest’);

var app = require(‘../app.js’);

describe(‘GET /’, function() {

it(‘respond with hello’, function(done) {

request(app).get(‘/’).expect(‘hello’, done);




In the above piece of code, the “supertest” library is imported. Then, it defines the action that must be encountered after receiving a “GET” request at the root of the website. It will eventually check response whether it is “Hello” or not.


  1. b) Run the test by executing the following command.


Command:      ./node_modules/.bin/mocha ./test/test.js


A green dot along with the statement reading “One test has passed” represents that your test was successful.


4.) Let’s push it on the GitHub.

After accomplishing the aforementioned steps successfully, simply add your new code to GitHub. This can be done with the following chunk of code.


Code Snippet:

git add .

git commit -m ‘Add node app’

git push origin master


With all these four steps you application has been successfully configured and synced with GitHub for automated testing and deployment.

Xicom Ltd – a leading Android App Development Services


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s