Getting Started with Jenkins: Installation and Setup
1.Installing Jenkins 2. Setup the Jenkins Console
What is CI-CD Pipeline
In modern software development, we use Continuous Integration and Continuous Delivery (CI/CD) to make things easier. It's like having a robot assistant that helps us build, test, and put our new code into action without much manual work. This way, we can create better software faster and with fewer mistakes.
Continuous Integration (CI):
CI is the practice of automatically integrating code changes from multiple developers into a shared repository frequently, typically multiple times a day. The main goal of CI is to detect integration issues early in the development cycle, thereby reducing the chances of conflicts and bugs that arise when multiple developers work on the same codebase.
Continuous Delivery (CD)
CD is an extension of CI that focuses on automating the software release process. It ensures that code changes are always in a deployable state and ready for production release. The ultimate goal of CD is to enable frequent and reliable software releases to end-users with minimal manual intervention.
Benefits of CI/CD
Faster time delivery: CI/CD streamlines the development and deployment process, reducing the time it takes to deliver new features and updates to end-users.
Higher software quality: Automated testing and validation catch bugs early, leading to a more stable and reliable codebase.
Risk reduction: Reduced the risk of issues being introduced in production. minimizing risks associated with manual processes.
Increased collaboration: CI/CD encourages collaboration among developers, testers, and operations teams, supports a culture of continuous improvement
What is Jenkins?
Jenkins is a powerful application that allows continuous integration and continuous delivery of projects, regardless of the platform you are working on.
It is a free source that can handle any kind of build or continuous integration. You can integrate Jenkins with a number of testing and deployment technologies. In this blog, we will explain how to install and unlock Jenkins on your server. How you can use Jenkins to build and test your software projects continuously
Why Jenkins?
Why do everything manually, if you have a tool that can automate your tasks called jenkins. It offers a seamless environment for automation, providing tools for building, deploying, and automating any project (CICD). Everyone says Jenkins is used only for CICD, I have started working in Jenkins with Simple tasks to automate repetitive manual activities. Its open-source nature and extensive Plugin Library integrate with other tools and services, such as Git, AWS, and Docker. makes it highly adaptable for various software development needs. Easy to Use and Scalable. Active community of users and contributors, providing support and resources to help users get the most out of the tool.
Install and Setup Jenkins
Step 1: Create an Ec2 instance
Instances can be t2-micro, 1 CPU, 1 GiB Memory, and ports 8080 , 80, 22 are open to allow incoming traffic
Step 1:Install Jenkins
1. To ensure that your software packages are up to date on your instance, use the following command to perform a quick software update:
sudo yum -y update
2. Jenkins requires Java to run, so first install Java. Install latest JDK using below command
sudo amazon-linux-extras install java-openjdk11
3. Add the Jenkins repo using the following command:
sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
4. Import a key file from Jenkins-CI to enable installation from the package:
sudo rpm --import
https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
5. Install Jenkins using below command
sudo yum install jenkins
Step 2:Starting Jenkins
1. We will start the Jenkins with below command
systemctl start jenkins
systemctl enable jenkins
2. Since above command doesn’t display output, we’ll use its status command to verify that it started successfully
systemctl status jenkins
3. If everything went well, the beginning of the output should show that the service is active and configured to start at boot
Output:
Step3: Setting up Jenkins
1. access your jenkins on http://13.127.252.11:8080
2. We will see “Unlock Jenkins” screen, which displays the location of the initial password
3. In the Ec2 server, we can use the cat command to display the password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
4. We’ll copy the password from the ec2 server and paste it into the “Administrator password” field, then click “Continue”. The next screen presents the option of installing suggested plugins or selecting specific plugins.
5. We’ll click the “Install suggested plugins” option, which will immediately begin the installation process.
6. When the installation is complete, we’ll be asked to set up the first admin user. It’s possible to skip this step and continue as admin using the initial password we used above, but we’ll create the user.
7. Once the first admin user is in place, you should see a “Jenkins is ready!” confirmation screen.
8. Click “Start using Jenkins” to visit the main Jenkins dashboard. Jenkins has been successfully installed.
Create your first freestyle Jenkins Job
1. Click on “New Item” at the top left-hand side of your dashboard or "Create a job"
2. In the next screen, 1)Enter the name of the item you want to create. We shall use the “first-project” for this demo. 2) Select Freestyle project 3) Click Ok.
3. Enter Project details : Enter the details of the project you want to test.
4. Go to Build Step. Add Build Step --> Execute shell --> Write command --> "java --version" and apply --> Save
5. Build Now
6. Console Output
Summary
In this blog, we discussed the importance of implementing Continuous Integration/Continuous Delivery (CI/CD) pipelines in software development and the role of Jenkins in automating the process of building, testing, and deploying code changes. CI/CD pipelines enable faster deployments, better quality, time-saving, and improved collaboration. Installation and setup of Jenkins. How to unlock jenkins console as well as How to create our first Jenkins Job.