Deploying An Application Using Jenkinsfile (original) (raw)

Last Updated : 22 Aug, 2025

Deploying an application with a Jenkinsfile automates building, testing, and deploying the app. It ensures consistent and repeatable deployments, making CI/CD more efficient. Jenkins Pipeline Components:

Deploying An Application Using Jenkinsfile

Here are the steps for deploying an application.

**Step 1: Log in to an AWS Account

Console-Home

**Step 2: Navigate to EC2 Dashboard

EC2-Dashboard

**Step 3: Launch Instance

Launching-Instance

Step 4: Configure Instance

Configuring-Instance

**Step 5: Configure Network Security Groups

Launcing-the-instance-finally

**Step 6: Connect To Instance

Connecting-to-the-Instance

**Step 7: Connect To EC2 Console

Connecting-To-EC2-Console

**Step 8: Install Jenkins

Now Install the jenkins and Java, with the following commands:

sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade

Add required dependencies for the jenkins package

sudo yum install java* -y
sudo yum install jenkins
sudo systemctl daemon-reload

Installation-Of-Jenkins

**Step 9: Verify Java And Jenkins

Verify the successful installation of jenkins and java with following commands:

java --version
jenkins --version

Verification-of-java-and-jenkins-softwares

**Step 10: Start Jenkins Server

systemctl enable jenkins --now

Starting-the-jenkins-Server

**Step 11: Access Jenkins Server

After successfully starting the jenkins server, go to the browser and enter the following url, you will the see the below jenkins server page.

http:[IP_Address]:8080

Accessing-Jenkins-server

**Step 12: Copy Jenkins Password

Copying-the-jenkins-password

**Step 13: Install Suggested Plugins

Installing-The-suggested-Plugins

**Step 14: Installation Of Plugins Completely

Installing-The-suggested-plugins

**Step 15: Using Default Admin User

15-Using-default-admin-user

**Step 16: Instance Configuration

Instance-Configuration

**Step 17: Create A Job

Now, create an item clicking on **New Item in this Jenkins Web page.

Creating-A-Job

**Step 18: Configure The Job

Configuring-the-job

**Step 19: Configure The Pipeline Job

Note: Change the mail id with your one.

pipeline {
agent any

stages {  
    stage('Build') {  
        steps {  
            sh 'echo "Building..."'  
            sh 'mvn clean package'  
        }  
    }  
      
    stage('Test') {  
        steps {  
            sh 'echo "Testing..."'  
            sh 'mvn test'  
        }  
    }  
      
    stage('Deploy') {  
        steps {  
            sh 'echo "Deploying..."'  
            // Add deployment steps here  
        }  
    }  
}  
  
post {  
    always {  
        sh 'echo "Cleaning up..."'  
    }  
      
    success {  
        mail to: 'developer@example.com',  
             subject: 'Pipeline Succeeded',  
             body: 'Your Jenkins Pipeline has completed successfully.'  
    }  
      
    failure {  
        mail to: 'admin@example.com',  
             subject: 'Pipeline Failed',  
             body: 'Your Jenkins Pipeline has failed. Please investigate.'  
    }  
}  

}

19-Configuring-The-pipeline-of-job

**Step 20: Successfully Jenkins Build

20-Successful-Jenkins-Build