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)
- Download and install the latest JDK version compatible with your operating system.
- Set the JAVA_HOME environment variable to the JDK installation directory.
Step 2: Install Apache Maven
- Download the latest Apache Maven binary distribution from the official website (https://maven.apache.org/download.cgi).
- Extract the downloaded archive to a directory on your system.
- Set the MAVEN_HOME environment variable to the Maven installation directory.
- Add the Maven bin directory to the system's PATH variable.
Step 3: Install Git
- Download and install Git from the official website (https://git-scm.com/downloads).
- 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
- Download and install Jenkins on your server or local machine by following the official installation guide (https://www.jenkins.io/doc/book/installing/).
- Start the Jenkins server and access the Jenkins web interface using a web browser.
Step 5: Set up Jenkins for CI
- 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.
- Create a new Jenkins pipeline project:
- Click on "New Item" on the Jenkins dashboard.
- Enter a name for the project (e.g., "MyJavaApp").
- Select "Pipeline" and click "OK."
- Configure the pipeline:
- Under the "Pipeline" section, choose "Pipeline script from SCM."
- Select "Git" as the SCM (Source Code Management) and provide the repository URL.
- Save the configuration.
Step 6: Create a Simple Java Project with Version Control
- Create a new directory for your Java project.
- Inside the project directory, create a new Java source file with a simple Java class (e.g., HelloWorld.java).
- 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
- In the Jenkins pipeline project, click on "Build Now" to manually trigger the first build.
- Verify that the build is successful.
Step 8: Test CI by Pushing Changes
- Make some changes to the HelloWorld.java file.
- 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
Post a Comment