How to Set Up Jenkins: A Step-by-Step Guide
Jenkins is a powerful open-source automation server that helps streamline the software development process by automating the build, testing, and deployment of applications. Setting up Jenkins for the first time might seem daunting, but with this step-by-step guide, you’ll have your Jenkins server up and running in no time.
Introduction
In today’s fast-paced development environment, automation is key to delivering high-quality software quickly. Jenkins, a leader in continuous integration and continuous delivery (CI/CD), is an essential tool for automating the parts of your development workflow. In this guide, we’ll walk you through the process of setting up Jenkins from scratch.
What You’ll Need
Before we dive into the setup, here’s what you’ll need:
A machine to install Jenkins on (this can be a local server, cloud server, or your personal computer)
Java Development Kit (JDK) installed (Jenkins requires Java to run)
Administrator access to the machine
Step 1: Install Java
Jenkins is a Java-based application, so the first step is to ensure that you have Java installed. If you already have Java installed, you can skip this step.
For Ubuntu/Debian:
sudo apt update
sudo apt install openjdk-11-jdk
For CentOS/RHEL:
sudo yum install java-11-openjdk-devel
For Windows:
Download the JDK installer from the Oracle website.
Run the installer and follow the on-screen instructions.
To verify the installation, open a terminal or command prompt and type:
java -version
This should display the installed Java version.
Step 2: Install Jenkins
With Java installed, you can now move on to installing Jenkins. Jenkins provides installation packages for various operating systems.
For Ubuntu/Debian:
wget -q -O - https://pkg.jenkins.io/debian/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
sudo apt install jenkins
For CentOS/RHEL:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
sudo yum install jenkins
For Windows:
Download the Jenkins Windows installer from the official Jenkins website.
Run the installer and follow the installation wizard.
Once Jenkins is installed, start the Jenkins service.
For Ubuntu/Debian:
sudo systemctl start jenkins
sudo systemctl enable jenkins
For CentOS/RHEL:
sudo systemctl start jenkins
sudo systemctl enable jenkins
For Windows:
Jenkins should start automatically after installation. If it doesn’t, you can start it manually through the Services panel.
Step 3: Access Jenkins
Now that Jenkins is running, you can access it via your web browser. By default, Jenkins runs on port 8080. Open your browser and go to:
http://localhost:8080
If you installed Jenkins on a remote server, replace localhost
with the server’s IP address.
Step 4: Unlock Jenkins
The first time you access Jenkins, you’ll be asked to unlock it using an initial admin password. To find this password, follow these steps:
For Linux:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
For Windows:
Navigate to
C:\Program Files (x86)\Jenkins\secrets\
.Open the
initialAdminPassword
file.
Copy the password and paste it into the Jenkins unlock page.
Step 5: Install Suggested Plugins
After unlocking Jenkins, you’ll be prompted to install plugins. Jenkins offers a variety of plugins to extend its functionality. It’s recommended to install the suggested plugins for a start.
Click on Install suggested plugins.
Jenkins will start downloading and installing the plugins. This may take a few minutes.
Step 6: Create an Admin User
Once the plugins are installed, you’ll be prompted to create your first admin user. Fill out the required fields:
Username
Password
Full Name
Email Address
Click Save and Continue when done.
Step 7: Configure the Jenkins URL
Next, you’ll need to configure the Jenkins URL. This is the URL where your Jenkins server can be accessed. Jenkins automatically detects the correct URL, but you can adjust it if necessary.
Verify the URL and click Save and Finish.
Step 8: Start Using Jenkins
Congratulations! Jenkins is now set up and ready to use. Click on Start using Jenkins to go to the Jenkins dashboard.
Step 9: Set Up Your First Job (Optional)
Now that Jenkins is up and running, you might want to set up your first job to get a feel for how Jenkins works.
On the Jenkins dashboard, click on New Item.
Enter a name for your job, select Freestyle project, and click OK.
In the job configuration page, you can set up various build steps, source control integration, and post-build actions.
Once configured, click Save and then Build Now to trigger the job.
Conclusion
Setting up Jenkins is the first step towards automating your software development pipeline. With Jenkins installed, you can now start exploring its powerful features and integrate it with other tools in your development ecosystem.
Jenkins is highly customizable, with hundreds of plugins available to tailor it to your specific needs. Whether you’re looking to automate your builds, run tests, or deploy your applications, Jenkins has got you covered.
Ready to take the next step? Check out our guide on creating CI/CD pipelines in Jenkins and start automating your workflow today!