Introduction
Jenkins is an open-source automation server widely used for Continuous Integration (CI) and Continuous Deployment (CD). This powerful tool helps developers automate parts of their software development process, making it easier to build, test, and deploy applications. In this blog post, we will cover how to install Jenkins on different operating systems, including Linux, macOS, and Windows. In this step-by-step guide I will teach you how to install Jenkins on Ubuntu Server 24.04, on MacOS, and on Windows.
1. Prerequisites
Before installing Jenkins, ensure that you have the following prerequisites:
- If Java is not installed, follow the installation instructions in this guide.
Java Development Kit (JDK): Jenkins requires JDK 8 or higher. You can verify whether Java is installed by executing the following command in your terminal:
java -version
2. Installing Jenkins on Linux
Step 1: Add Jenkins Repository
To install Jenkins, you need to add its repository to your package manager. Start by importing the GPG keys:
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
Then, add the Jenkins repository:
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
Step 2: Update Package Index Again
After adding the Jenkins repository, update the package index once more:
sudo apt update
Step 3: Install Jenkins
Now, you can install Jenkins using the following command:
sudo apt install jenkins
Step 4: Start Jenkins Service
Once the installation is complete, start the Jenkins service and enable it to run at startup:
sudo systemctl start jenkins
sudo systemctl enable jenkins
Step 5: Access Jenkins
Jenkins runs on port 8080 by default. To access the web interface, open your web browser and navigate to:
http://localhost:8080
3. Installing Jenkins on macOS
Step 1: Install Homebrew
If you don’t have Homebrew installed on your macOS, you can install it by running the following command in the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install Java
Use Homebrew to install Java. Execute the following command:
brew install openjdk@11
You may need to link the Java installation:
brew link --force --overwrite openjdk@11
Step 3: Install Jenkins
Install Jenkins using Homebrew:
brew install jenkins-lts
Step 4: Start Jenkins
You can start Jenkins as a background service using Homebrew:
brew services start jenkins-lts
Step 5: Access Jenkins
Open your web browser and navigate to:
4. Installing Jenkins on Windows
Step 1: Download Jenkins
Visit the Jenkins download page and download the Windows installer (MSI file).
Step 2: Run the Installer
Double-click the downloaded MSI file and follow the installation wizard steps to install Jenkins.
Step 3: Install Java
If you haven't installed Java yet, download the JDK from the AdoptOpenJDK website and install it.
Step 4: Start Jenkins
After installation, Jenkins should start automatically. If it doesn't, you can manually start it by searching for Jenkins in the Start menu.
Step 5: Access Jenkins
Open your web browser and go to:
5. Unlocking Jenkins
When you access Jenkins for the first time, you will need to unlock it:
Step 1: Get the Unlock Key
Retrieve the initial Admin password stored in a file. For Linux/macOS, run:
cat /var/lib/jenkins/secrets/initialAdminPassword
For Windows, the path is:
C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword
Step 2: Enter the Password
Copy the password from the file and paste it into the Jenkins setup wizard, then click "Continue."
6. Customizing Jenkins
After unlocking Jenkins, you will be prompted to install suggested plugins or select specific plugins based on your project's requirements. Once the installation is complete, you will be asked to create an admin user. Fill in the required details and click "Save and Finish." But, detailed guidance on customizing Jenkins—covering plugins, configuration tweaks, and user interface enhancements—will be explored in a separate post.
Conclusion
Congratulations! You have successfully installed Jenkins on your machine. You are now ready to start using Jenkins for your continuous integration and continuous delivery processes. In upcoming posts, we will explore how to configure Jenkins, create jobs, and integrate Jenkins with other tools in your development pipeline. By mastering Jenkins, you'll significantly enhance your development workflow and facilitate faster software delivery.