Getting Started with Jenkins

Getting Started with Jenkins

Introduction

Jenkins is a widely used open-source automation tool for continuous integration and continuous delivery (CI/CD) of applications. It allows developers to build, test, and deploy their code in a timely and efficient manner, bringing collaboration and automation to the development process.

In this article, we will discuss how to get started with Jenkins for CI/CD.

Prerequisites

Before getting started with Jenkins, you need to have:

  • A good understanding of Version Control System (VCS) tools like Git, SVN, etc.

  • An understanding of the principles of Continuous Integration and Continuous Deployment.

  • An understanding of the software development life cycle (SDLC).

  • A system with Java installed.

Installing Jenkins

Jenkins can be installed on multiple platforms, including Windows, Linux, and macOS. In this tutorial, we will be installing Jenkins on Ubuntu.

Step 1: Installing Java

First, you need to install Java on your system. You can install the latest version of Java by running the following command:

sudo apt-get install default-jre

Step 2: Adding the Jenkins Repository

Next, you need to add the Jenkins repository key to your system with the following command:

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

Once you have added the key, you need to add the Jenkins repository to your system:

sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

Step 3: Installing Jenkins

After adding the Jenkins repository, you can install Jenkins with the following commands:

sudo apt-get update  
sudo apt-get install jenkins

Step 4: Starting Jenkins

Once Jenkins is installed, it will start automatically. You can check the status of Jenkins with the following command:

sudo systemctl status jenkins

By default, Jenkins runs on port 8080. You can access Jenkins through your browser at http://your_server_ip:8080.

Configuring Jenkins

Once you have installed Jenkins, you need to configure it to start using it for CI/CD.

Step 1: Creating a Jenkins Job

The first thing you need to do is create a Jenkins job. A job in Jenkins is a specific task that needs to be performed, such as compiling code, running unit tests, deploying code, etc.

To create a new Jenkins job:

  1. Click on "New Item" on the Jenkins dashboard.

  2. Enter a name for your job and select "Freestyle project".

  3. Click "OK".

Step 2: Configuring the Jenkins Job

After creating the job, you need to configure it to perform the necessary tasks. For example, if you want to compile code, you need to specify the path of your source code and the compiler to use.

To configure a Jenkins job:

  1. Under the "Configure" tab, enter the necessary details for your job.

  2. Add any necessary build steps, such as running tests, compiling code, deploying to a server, etc.

  3. Configure any necessary triggers for the job, such as running the job when code is pushed to a repository.

Step 3: Running the Jenkins Job

Once the job is configured, you can run it by clicking on the "Build Now" button. Jenkins will then run the job and perform the configured tasks.

Conclusion

In conclusion, Jenkins is a powerful tool that can help automate many tasks in the software development process. With the proper configuration and setup, Jenkins can significantly improve the speed and efficiency of the development process.