Introduction
In the fast-paced world of software development, Continuous Integration (CI) and Continuous Delivery (CD) have become essential practices for ensuring the reliability and efficiency of code deployment. Jenkins, an open-source automation server, plays a crucial role in setting up robust CI/CD pipelines. In this guide, we’ll walk you through the process of setting up a CI/CD pipeline using Jenkins on Red Hat Enterprise Linux 9 (RHEL 9). Follow these step-by-step instructions to streamline your development and deployment workflows.

Photo by Tom Fisk from Pexels.com
Prerequisites
Before diving into the installation and configuration, make sure you have the following prerequisites in place:
- A running instance of RHEL 9 with administrative privileges.
- A stable internet connection for downloading necessary packages.
CI/CD with Jenkins on RHEL9
Begin by updating your system and installing Java Development Kit (JDK). Jenkins is built on Java, so this step is crucial.
$ sudo dnf update
$ sudo dnf install java-11-openjdk-develNow, download and install the Jenkins repository key and enable the Jenkins repository:
$ sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
$ sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.keyInstall Jenkins:
$ sudo dnf install jenkinsStart and enable Jenkins service:
$ sudo systemctl start jenkins
$ sudo systemctl enable jenkinsStep 1: Configure Jenkins:
Access Jenkins through your web browser by navigating to http://<your-server-IP>:8080. Retrieve the initial administrator password using:
$ sudo cat /var/lib/jenkins/secrets/initialAdminPasswordFollow the on-screen instructions to complete the Jenkins setup.
Step 2: Install Required Plugins
Once Jenkins is up and running, install the necessary plugins to support your CI/CD workflow. Common plugins include Git, GitHub, Docker, and Pipeline.
- Navigate to Jenkins dashboard.
- Click on “Manage Jenkins” > “Manage Plugins.”
- Go to the “Available” tab, search for the required plugins, and install them.
Step 3: Create a New Jenkins Job
- Click on “New Item” on the Jenkins dashboard.
- Enter a job name and select the type of project (freestyle project or pipeline).
- Configure the job with your source code repository, build triggers, and other settings.
CI/CD with Jenkins on RHEL9: Configuration
Step 4: Configure CI/CD Pipeline Script
If you chose the Pipeline job type, you’ll need to define your CI/CD pipeline using the Jenkinsfile. Here’s a basic example:
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build') {
steps {
// Your build commands
}
}
stage('Test') {
steps {
// Your testing commands
}
}
stage('Deploy') {
steps {
// Your deployment commands
}
}
}
}Customize the stages based on your project’s requirements.
Step 5: Save and Run Your Jenkins Job
Save your Jenkins job configuration and trigger a manual build or wait for the defined triggers to start the CI/CD pipeline.
No comments:
Post a Comment