DevOps Day-81: Project -2 Web-APP

DevOps Day-81: Project -2 Web-APP

In today's article we will explain the Project 2 Web-APP with the help of Jenkins Declarative Pipeline.

Table of Contents:

Project Description

Pre-requisites

Project-Steps

Project Description:

The Project is about automating the deployment process of a web application using Jenkins and its declarative syntax. The pipeline includes stages like building, testing and Deploying to a staging environment. It also includes running acceptance tests and deploying to production if all tests pass.

Pre-requisites:

1 Create an EC2 instance in the AWS management console with the required storage.

2 Install jenkins and Docker in the EC2 instance.

Project Steps:

1 Navigate to the Jenkins dashboard and go to new item. Then select Pipeline and create the project.

Article content
Article content

2 In the genereal section provide the project description and also the GitHub project URL.

Article content

3 In the build trigger section select the GitHub webhook trigger option.

Ensure the Webhook is configures in GitHub.

Article content

4 Ensure the project has a Docker file in GitHub.

Article content

5 Write the declarative pipeline code which is a groovy syntax code to set up the project pipeline.

Agent:- Agents is a different servers that are linked to the master Jenkins server. An agent can be set up in the pipeline to run the pipelines in different agents. In this project, we are with the default agent.

Stages:- Stages contain different steps to be executed as part of the project pipeline.

In this project we have the 3 stages:

Code:- The code stage pulls the code from GitHub to build and execute the Pipeline in further steps.

Build and Test:- The stage builds the image of the app code from the docker file.

Run:- This stage runs the Container in the server and makes the application up.

pipeline {
        agent any
        stages{
            stage('Code'){
                steps{
                    git url: 'https://github.com/Maninderit/node-todo-cicd1.git', branch: 'master' 
                }
            }
            stage('Build and Test'){
                steps{
                    echo "$USER"
                    sh 'docker build -t webapp .'
                    echo "build and ttest completed"
                }
            }
            stage('Run'){
                steps{
                    sh "docker run -d -p 8000:8000 webapp"
                }
            }
        }       
        

1 After writing the detailed pipeline groovy script in the project configuration apply and save the Project.

Article content
Article content

2 Navigate to the project and click on Build Now to execute the project.

Article content

3 We can see the successful console output and the stages that are completed in its stage executions as shown in the above and below screenshots.

Article content
Article content
Article content
Article content

4 Ensure to open the port 8000 in the security group associated with the EC2 instance.

Article content

5 Finally, navigate to the web-app URL and we can see the application is up and Running.

Article content

Hope I helped you in understanding the concept in a better way!!

Happy Learning

SAMEER HASHIM : )



To view or add a comment, sign in

More articles by Sameer Hashim

Others also viewed

Explore content categories