How to Install Jenkins on Mac

Updated: February 3, 2024 By: Guest Contributor Post a comment

Overview

Jenkins is an open-source automation server that enables developers around the globe to reliably build, test, and deploy their software. The beauty of Jenkins is its vast plugin ecosystem which accommodates various development, testing, and deployment technologies. In this tutorial, we will guide you through the steps to install Jenkins on a Mac. Whether you are setting up a CI/CD pipeline or just want to experiment with Jenkins, this guide will help you get started.

Prerequisites

  • A Mac machine with macOS installed.
  • Basic terminal knowledge.
  • Homebrew installed. If not, you can get it from https://brew.sh/.

Step 1: Install Java

Jenkins is a Java-based application, so the first step is to ensure you have Java installed. Jenkins requires Java 8 or 11. You can check your Java version by opening a terminal and typing:

java -version

If Java is not installed or the version is not compatible, you can install Java using Homebrew:

brew install openjdk@11

After installation, you may need to add Java to your PATH. For this, you can run:

echo 'export PATH="/usr/local/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Step 2: Install Jenkins

With Java in place, you can now proceed to install Jenkins. Jenkins can be installed using Homebrew, which simplifies the installation process on Mac:

brew install jenkins-lts

After the installation is complete, you can start Jenkins by running:

brew services start jenkins-lts

This will start Jenkins and have it run automatically at boot.

Step 3: Accessing Jenkins

Once Jenkins is running, you can access the Jenkins dashboard from your web browser. Open your browser and go to:

http://localhost:8080

The first time you access the dashboard, Jenkins will ask for an initial admin password. You can find this password by running the following command in your terminal:

cat /usr/local/var/jenkins_home/secrets/initialAdminPassword

Copy the password, paste it into your Jenkins dashboard, and click “Continue”.

Step 4: Customize Jenkins (Optional)

After providing the initial admin password, you’ll be prompted to customize Jenkins using the suggested plugins or selecting plugins to install. For most users, the suggested plugins provide a good starting point. However, you can select “Select plugins to install” to choose specific plugins based on your project requirements.

Step 5: Create Your First Jenkins Job

With Jenkins now fully installed and configured, let’s create a simple “Hello World” Jenkins job:

  1. From the Jenkins dashboard, click on “New Item”.
  2. Enter a name for your job, select “Freestyle project”, and click “OK”.
  3. In the job configuration, scroll down to the “Build” section.
  4. Click “Add build step” and select “Execute shell”.
  5. In the command box that appears, type: echo "Hello, World!"
  6. Click “Save”.
  7. On the job’s page, click “Build Now” to run your new job.

You should see your job queued and then successfully executed, displaying “Hello, World!” in the build output.

Conclusion

Installing Jenkins on a Mac is straightforward, thanks to Homebrew. With Jenkins, you have a powerful tool at your disposal for automating a variety of software development processes. Remember, the true power of Jenkins comes from its plugins, so don’t hesitate to explore the available plugins and customize Jenkins to fit your workflow.

Keep in mind that continuous learning and experimentation with Jenkins will help you uncover its full potential and how it can best serve your development needs. Happy building!