Open In App

Deploying An Application Using Jenkinsfile

In the IT world, initially, there were silos between the development and testing teams that created delays in moving the application to user availability. DevOps came into the picture with a culture practice that brings automation with a lot of tools. Jenkins is one of the popular CI/CD tools. Jenkinsfile methodology helps automate the entire pipeline. In this article, we will guide you on how to deploy an application using Jenkinsfile.

Understanding Of Primary Terminologies

Deploying An Application Using Jenkinsfile: A Step-By-Step Guide

Step 1: Log in to an AWS Account



Step 2: Navigate to EC2 Dashboard

Step 3: Launch Instance



Step 4: Configure Instance

Step 5: Configure Network Security Groups

Step 6: Connect To Instance

Step 7: Connect 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

Step 9: Verify Java And Jenkins

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

java --version
jenkins --version

Step 10: Start Jenkins Server

systemctl enable jenkins --now

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

Step 12: Copy Jenkins Password

Step 13: Install Suggested Plugins

Step 14: Installation Of Plugins Completely

Step 15: Using Default Admin User

Step 16: Instance Configuration

Step 17: Create A Job

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

Step 18: Configure 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.'
}
}
}

Step 20: Successfully Jenkins Build

Deploying An Application Using Jenkinsfile – FAQ’s

What is a Jenkinsfile?

Jenkinsfile is a text based file that used for the defining the pipeline of a jenkins project with providing continuous integration and deployment.

How do I deploy an application using Jenkinsfile?

By defining deployment stages and tasks in Jenkinsfile and specifying the build, test and deployment steps with automation process.

Can I use Jenkinsfile to deploy different types of applications?

Yes, Jenkinsfile supports to deploy various types of applications such as web applications, APIs, Mobile Apps and Customizable scripts.

Does Jenkinsfile support version control integration?

yes, Jenkinsfile support version control systems like Git with providing credentials and ensuring consistency and tracebility.


Article Tags :