Skip to main content

Experiment to Setup Jenkins and Demonstrating Continuous Integration

 Title: Setting up Jenkins and Demonstrating Continuous Integration

Objective:

The objective of this experiment is to set up Jenkins and demonstrate Continuous Integration (CI) by automating the build process of a simple Java project whenever changes are pushed to the version control repository.

Prerequisites:

  • Java Development Kit (JDK) installed on your system
  • Apache Maven installed on your system
  • Git installed on your system
  • Jenkins installed on a server or local machine

Experiment Steps:

Step 1: Install Java Development Kit (JDK)

  1. Download and install the latest JDK version compatible with your operating system.
  2. Set the JAVA_HOME environment variable to the JDK installation directory.

Step 2: Install Apache Maven

  1. Download the latest Apache Maven binary distribution from the official website (https://maven.apache.org/download.cgi).
  2. Extract the downloaded archive to a directory on your system.
  3. Set the MAVEN_HOME environment variable to the Maven installation directory.
  4. Add the Maven bin directory to the system's PATH variable.

Step 3: Install Git

  1. Download and install Git from the official website (https://git-scm.com/downloads).
  2. Configure Git with your username and email using the following commands:


git config --global user.name "Your Name"

git config --global user.email "you@example.com"


Step 4: Install Jenkins

  1. Download and install Jenkins on your server or local machine by following the official installation guide (https://www.jenkins.io/doc/book/installing/).
  2. Start the Jenkins server and access the Jenkins web interface using a web browser.

Step 5: Set up Jenkins for CI

  1. Access the Jenkins web interface (usually at http://localhost:8080) and complete the initial setup by providing the Administrator password and installing the recommended plugins.
  2. Create a new Jenkins pipeline project:
  3. Click on "New Item" on the Jenkins dashboard.
  4. Enter a name for the project (e.g., "MyJavaApp").
  5. Select "Pipeline" and click "OK."
  6. Configure the pipeline:
  7. Under the "Pipeline" section, choose "Pipeline script from SCM."
  8. Select "Git" as the SCM (Source Code Management) and provide the repository URL.
  9. Save the configuration.

Step 6: Create a Simple Java Project with Version Control

  1. Create a new directory for your Java project.
  2. Inside the project directory, create a new Java source file with a simple Java class (e.g., HelloWorld.java).
  3. Initialize Git in the project directory:


git init

  • Add the Java source file to the Git repository:

git add HelloWorld.java

  • Commit the initial version of the project:

git commit -m "Initial commit"

  • Create a remote repository (e.g., on GitHub, GitLab, or Bitbucket) and link it to the local repository:

git remote add origin <repository_url>

git push -u origin master


Step 7: Configure Jenkins to Trigger CI

  1. In the Jenkins pipeline project, click on "Build Now" to manually trigger the first build.
  2. Verify that the build is successful.

Step 8: Test CI by Pushing Changes

  1. Make some changes to the HelloWorld.java file.
  2. Commit the changes to the Git repository:

git add HelloWorld.java

git commit -m "Updated HelloWorld.java"

  • Push the changes to the remote repository:

git push origin master

  • Observe that Jenkins automatically triggers a new build due to the code changes.

Conclusion:

In this experiment, we successfully set up Jenkins and demonstrated Continuous Integration (CI) by automating the build process of a simple Java project whenever changes were pushed to the version control repository. Jenkins continuously monitored the repository for changes and automatically initiated the build, ensuring that the application remained in a deployable state at all times. CI practices help streamline development workflows, reduce integration issues, and improve collaboration among development teams.

Comments

Popular posts from this blog

Experiment No. 5 Title: Applying CI/CD Principles to Web Development Using Jenkins, Git, and Local HTTP Server

  Experiment No. 5 Title: Applying CI/CD Principles to Web Development Using Jenkins, Git, and Local HTTP Server  Objective: The objective of this experiment is to set up a CI/CD pipeline for a web development project using Jenkins, Git, and webhooks, without the need for a Jenkinsfile. You will learn how to automatically build and deploy a web application to a local HTTP server whenever changes are pushed to the Git repository, using Jenkins' "Execute Shell" build step. Introduction: Continuous Integration and Continuous Deployment (CI/CD) is a critical practice in modern software development, allowing teams to automate the building, testing, and deployment of applications. This process ensures that software updates are consistently and reliably delivered to end-users, leading to improved development efficiency and product quality. In this context, this introduction sets the stage for an exploration of how to apply CI/CD principles specifically to web development using J

Experiment No. 10 Title: Create the GitHub Account to demonstrate CI/CD pipeline using Cloud Platform.

  Experiment No. 10 Title: Create the GitHub Account to demonstrate CI/CD pipeline using Cloud Platform. Objective: The objective of this experiment is to help you create a GitHub account and set up a basic CI/CD pipeline on GCP. You will learn how to connect your GitHub repository to GCP, configure CI/CD using Cloud Build, and automatically deploy web pages to an Apache web server when code is pushed to your repository. Introduction: Continuous Integration and Continuous Deployment (CI/CD) pipelines are essential for automating the deployment of web applications. In this experiment, we will guide you through creating a GitHub account and setting up a basic CI/CD pipeline using Google Cloud Platform (GCP) to copy web pages for an Apache HTTP web application. Continuous Integration and Continuous Deployment (CI/CD) is a crucial practice in modern software development. It involves automating the processes of code integration, testing, and deployment to ensure that software changes are co

Experiment No. 6 Title: Exploring Containerization and Application Deployment with Docker

  Experiment No. 6 Title: Exploring Containerization and Application Deployment with Docker  Objective: The objective of this experiment is to provide hands-on experience with Docker containerization and application deployment by deploying an Apache web server in a Docker container. By the end of this experiment, you will understand the basics of Docker, how to create Docker containers, and how to deploy a simple web server application. Introduction Containerization is a technology that has revolutionised the way applications are developed, deployed, and managed in the modern IT landscape. It provides a standardised and efficient way to package, distribute, and run software applications and their dependencies in isolated environments called containers. Containerization technology has gained immense popularity, with Docker being one of the most well-known containerization platforms. This introduction explores the fundamental concepts of containerization, its benefits, and how it differs