Setting Up Jenkins on Ubuntu
Jenkins is a popular open-source automation server that is widely used for continuous integration and continuous deployment (CI/CD) of software projects. It provides a flexible platform for automating various software development tasks, such as building, testing, and deploying applications. In this guide, we'll walk through the steps to set up Jenkins on an Ubuntu operating system.
Prerequisites
Before you begin, make sure you have the following prerequisites:
- Ubuntu Operating System: This guide assumes you're using Ubuntu as your operating system. The steps may vary slightly for other Linux distributions.
- Java Runtime Environment (JRE): Jenkins requires Java to be installed on the system. You can install the OpenJDK version of Java, which is a free and open-source implementation of the Java Platform.
- Git (Optional): If you plan to use Jenkins for version control and source code management, you'll need to have Git installed on your system.
Step 1: Install Java
- Update the package index:
sudo apt update
- Install the OpenJDK Java Development Kit (JDK):
sudo apt install openjdk-11-jdk
- Verify the Java installation by checking the version:
You should see the output indicating the installed Java version.java -version
Step 2: Install Jenkins
- Add the Jenkins repository to your system's sources list:
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add - sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
- Update the package index and install Jenkins:
sudo apt update sudo apt install jenkins
- Start the Jenkins service:
sudo systemctl start jenkins
- Check the status of the Jenkins service:
You should see the service running and active.sudo systemctl status jenkins
Step 3: Access the Jenkins Web Interface
- By default, Jenkins runs on port 8080. Open a web browser and navigate to
http://localhost:8080
orhttp://your-server-ip:8080
to access the Jenkins web interface. - You'll be prompted to enter the initial administrator password. This password is stored in the
/var/lib/jenkins/secrets/initialAdminPassword
file. You can retrieve it using the following command:sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Copy the password and enter it in the web interface.
- You'll then be prompted to install the recommended plugins or select the plugins you want to install. Choose the recommended plugins to get started.
- After the installation process is complete, you'll be asked to create the first admin user. Follow the on-screen instructions to create the user.
Step 4: Configure Jenkins
Once you've logged in, you can start configuring Jenkins to suit your needs. Some common configuration tasks include:
- Configuring Global Security Settings: Set up user authentication, authorization, and other security-related settings.
- Configuring Global Tool Configuration: Set up the paths for various tools, such as Java, Git, and other build tools.
- Configuring Plugins: Install additional plugins to extend the functionality of Jenkins, such as version control, notification, and deployment plugins.
- Creating and Configuring Jobs: Set up your project's build, test, and deployment jobs.
Here's a Mermaid diagram that illustrates the overall process of setting up Jenkins on Ubuntu:
By following these steps, you should have a fully functional Jenkins server set up on your Ubuntu system, ready to automate your software development workflows.