(Day -22)90DaysOfDevOps Challenge: Exploring Jenkins for Continuous Integration
Introduction:
Welcome back to another day of the 90DaysOfDevOps challenge! Today, we'll dive into Jenkins, a powerful open-source automation server that plays a crucial role in the world of Continuous Integration and Continuous Deployment (CI/CD).
Jenkins: An Overview
What is Jenkins?
Jenkins is an open-source automation server that helps automate the building, testing, and deployment of code. It facilitates Continuous Integration and Continuous Deployment, enabling developers to deliver high-quality software quickly.
Jenkins Installation
To get started with Jenkins, you need to install it on your server. Let's go through the installation process step by step.
Step 1: Prerequisites
Before installing Jenkins, make sure you have Java installed on your server (EC2 instance in this case).
# Install Java on your EC2 instance
sudo apt update
sudo apt install fontconfig openjdk-17-jre
java -version
openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Debian-1deb12u1, mixed mode, sharing)
Step 2: Installing Jenkins
2.1 Download and Install Jenkins
# Download and install Jenkins using the Long-Term Support (LTS) release
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian/jenkins.io-2023.key
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
Step 3: Configure EC2 Security Group
To access Jenkins, we need to allow traffic on port 8080. Update your EC2 instance's inbound rules accordingly.
Step 4: Unlock Jenkins
Access Jenkins by navigating to
http://<your_ec2_ip>:8080
in your browser.Retrieve the initial admin password from the EC2 instance using the following commands:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and paste it into the Jenkins web page to unlock Jenkins.
Step 5: Getting Started
Press Enter
installation of plugins
Create your Jenkins account.
Customize your Jenkins installation by choosing the recommended plugins.
Hello, World with Jenkins
Now that Jenkins is set up, let's create a simple Jenkins job to print "Hello, World."
Click on "New Item" on the Jenkins dashboard.
Enter a name for your project (e.g., "HelloWorldJob") and choose "Freestyle project."
In the configuration, add a build step to execute a shell command:
echo "Hello, World!"
Save the configuration and click on "Build Now" to run the job.
Congratulations! You've successfully set up Jenkins, configured an EC2 instance, and created your first Jenkins job.
Stay tuned for more DevOps adventures as we continue our 90DaysOfDevOps challenge. Happy coding!