🚀 Think you’ve got what it takes for a career in Data? Find out in just one minute!

Jenkins: What is it? How to use it?

-
3
 m de lecture
-

Jenkins is a widely used open-source automation server for continuous development, testing, and deployment of applications. It automates repetitive tasks and facilitates code integration within a project, ensuring better productivity and a reduction in human errors. With a modular architecture and a vast number of plugins, Jenkins seamlessly integrates with popular tools.

What is CI/CD?

CI/CD, or “Continuous Integration / Continuous Delivery”, is a development practice aimed at automating the stages of an application’s lifecycle. It minimizes human errors, speeds up delivery times, and enhances application quality.

  • Continuous Integration (CI) allows developers to frequently commit code to a shared repository. Jenkins automatically ensures each change is compiled, tested, and validated before being integrated into the main project.
  • Continuous Deployment (CD) ensures that once the code is validated, it is automatically made available for deployment, whether in a test, pre-production, or production environment.

Why use Jenkins?

Jenkins is highly popular for automating repetitive tasks and aiding developers and DevOps teams. Here are the primary reasons why Jenkins is an essential choice:

Open-source and flexible tool

Jenkins is entirely open-source, meaning it’s free and supported by an active community that continuously contributes to its enhancement.

Its modular architecture is backed by thousands of plugins, allowing it to be adapted to any requirement.

Automation and time-saving

Jenkins enables automation of the entire development cycle, from the initial build to the final deployment. It can execute complex tasks without human intervention, enabling teams to focus on coding and innovation rather than repetitive manual processes.

Continuous Integration and Continuous Delivery (CI/CD)

Jenkins is one of the most utilized tools for setting up CI/CD pipelines. These pipelines facilitate faster and more reliable integration, testing, and delivery of code.

Compatibility with all platforms

Jenkins is cross-platform. It can be installed locally, run in a Docker container, deployed on on-premise servers, or hosted in the cloud. This flexibility allows teams to use it in varied infrastructures, regardless of their working environment.

Advanced pipeline management with Jenkinsfile

With Jenkins, you can define CI/CD pipelines as code through a file called Jenkinsfile. This file allows you to:

  • Precisely describe pipeline steps (build, tests, validation, deployment).
  • Easily version and share pipeline configurations.
  • Facilitate collaboration between DevOps teams and developers.

An active community and extensive support

As a mature open-source project, Jenkins boasts a vast community that contributes to its improvement and regularly offers updates and new plugins.

For companies requiring advanced support, several third-party services also offer commercial solutions based on Jenkins.

Installation and configuration

Jenkins is a powerful yet simple tool to install. This guide explains how to install Jenkins on Linux, along with its initial configuration to get started.

Installation

1. First, it is necessary to add the Jenkins repository and update the packages:

sudo apt update && sudo apt install -y fontconfig openjdk-17-jre
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update

2. Jenkins installation is then done as follows:

sudo apt install -y jenkins

3. Start the Jenkins service and check its status:

sudo systemctl start jenkins
sudo systemctl status jenkins

4. Access its web interface:

It is available here by default: http://localhost:8080.

If you prefer installation via Docker, the command is as follows:

docker run -p 8080:8080 -p 50000:50000 -d --name jenkins jenkins/jenkins:lts

Initial configuration

Upon first accessing Jenkins, an initial password will be required. It is available via this command:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

You will then be able to create new users and modify the administrator account.

Subsequently, some plugins that may be essential include:

  • Pipeline: to manage CI/CD workflows.
  • Git: for integration with GitHub/GitLab/Bitbucket repositories.
  • Docker: if you want to run builds in containers.
  • Blue Ocean: a modern interface for managing pipelines.

Creating the first job

In the Jenkins interface, select New Job. After providing a name, select Freestyle Project.

Then add a repository in Source Code Management, for example https://github.com/dst-project.git

Add a simple shell script to test, for example:

echo "Build en cours..."
mvn clean package

After saving, click on Run build to see Jenkins perform the actions.

In conclusion

Jenkins is an essential tool for continuous integration and deployment. Its flexibility, rich plugin ecosystem, and active community make it a preferred solution for teams wishing to accelerate and secure their development cycles.

Facebook
Twitter
LinkedIn

DataScientest News

Sign up for our Newsletter to receive our guides, tutorials, events, and the latest news directly in your inbox.

You are not available?

Leave us your e-mail, so that we can send you your new articles when they are published!
icon newsletter

DataNews

Get monthly insider insights from experts directly in your mailbox