Thanksgiving Sale - upGrad KnowledgeHut-mobile

HomeBlogDevOpsHow to Install Jenkins on Mac? [Step-By-Step Guide]

How to Install Jenkins on Mac? [Step-By-Step Guide]

Published
27th May, 2024
Views
view count loader
Read it in
8 Mins
In this article
    How to Install Jenkins on Mac? [Step-By-Step Guide]

    Jenkins is a Java-built open-source Continuous Integration (CI) and Continuous Deployment (CD) platform. Basically, Jenkins builds software projects, checks and deploys them. This is one of the most practical programming tools you can master, and today we will show you how to install Jenkins on macOS, and how to use this powerful tool to activate your VPS server. VPS copies a dedicated server environment in a shared server.

    Jenkins is loved by teams of all sizes, for different language projects like Java, Ruby, Dot Net, PHP etc. Jenkins is a platform that is autonomous, and can be used on Windows, Mac or any other operating system.

    In this article, we will learn how to install Jenkins on Mac OS. In addition, check the detailed blog on Install Jenkins on Ubuntu

    What is Jenkins? 

    Jenkins is an open-source system that supports continuous development of integration and delivery, which allows a series of tasks for making a software product – building, testing and deployment, to be automated.

    Jenkins includes plug-ins facilitating continuous integration. The process often provides continuous integration, allowing developers and DevOps engineers to produce new builds effortlessly. That’s why it's important to follow Jenkins download Mac or Windows for streamlining processes and testing software easily. In my opinion, you can also use different testing and deployment strategies when continuously releasing the software.

    • Easy to use: simple, intuitive, and visually appealing user interface
    • Extensibility: Jenkins is highly versatile and easy to adapt to your requirements. With various functionalities, there are thousands of open-source Plugins.

    Jenkins supports various version control systems, code indicators, notifiers, user interface adaptations, and more!

    How Does Jenkins Work?

    As a WAR archive and as an Installer package, Jenkins is distributed as a Homebrew package, an image in the Docker and as source code for the main operating systems. Most of the source code is in Java and contains several Groovy, Ruby, and Antlr files.

    You can run the Jenkins WAR on a Java application server such as Tomcat on your own or as a servlet. In any event, the web user interface is created and calls to its REST API are accepted.

    When you first run Jenkins, you create a long random password for the administrative user, which you may paste in your first webpage to unlock the installation.

    Prerequisites to Install Jenkins on Mac

    We will be going to run multiple jobs on Jenkins, so we need some proper configurations.

    A. Hardware Requirements

    • Minimum requirement:
      • RAM– 256 MB 
      • Storage- 1 GB of Hard Disk Space 
    • For small teams(recommended):
      • RAM- 4 GB 
      • Storage- more than 50 GB of Hard Disk Space 

    B. Software Requirements

    The following list shows the minimum software requirements:

    • Java: Java Development Kit (JDK) or Java Runtime Environment (JRE). 
    • Web Browser: Any browser such as Google Chrome, Mozilla Firefox, Microsoft Edge, Safari
    • Operating System: macOS

    Two Ways to Install Jenkins on macOS

    We will discuss two ways to install Jenkins on mac:

    • Using Homebrew package
    • Using Docker

    Method 1: How to Install Jenkins on Mac Using Homebrew

    Step1: Install Homebrew

    You can install Homebrew with the following command:

    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    You can check the Homebrew installation using:

    $ brew  -–version

    Step 2: Install Java

    Skip to the next section if you have Java already installed on your system.

    Being an open-source Java application, Jenkins requires the installation of OpenJDK 8 on your system. The apt repositories can directly access OpenJDK 8.

    The installation of OpenJDK from standard repositories is recommended. Open and enter the following in the terminal window:

    $ brew install java

    Step 3: Install Jenkins

    After Homebrew has been installed, it is required to execute the command that downloads and installs the latest version of Jenkins' Long-Term Support (LTS).

    $ brew install jenkins-lts

    Step 4: Start the Server

    You can run the following command to start the Jenkins server finally.

    $ brew services start jenkins-lts

    The above command will start the Jenkins server soon. 

    The port will be 8080. You can check it by visiting Jenkins on its default 8080 port with your server domain name or IP address: http://localhost:8080/

    Step 5: Unlock Jenkins

    The Unlock Jenkins screen displays the initial password's location:

    Use the cat command to display the password:

    $ cat <path  you receive after visiting http://localhost:8080/>

    In this case,

    $ cat /Users/ijs/.jenkins/secrets/initialAdminPassword

    Copy the 32-character password and paste it into the Administrator Password field, then click Continue.

    We will discuss the steps to complete the setup Jenkins on mac process at the end in the section How to configure Jenkins?

    Method 2: Install Jenkins in macOS Using Docker

    Please note that recent versions of Windows were equipped with native support for running Docker images, while Jenkins still provides only Linux-based Docker images. Thus, most of the commands that are outlined above work well with Windows and macOS because they run Linux Docker images via virtualization.

    Follow the below procedure to install Jenkins MacOS from a Docker image

    Step 1: Install Docker

    It's pretty easy to install Docker on Mac. It has a file with the .dmg graphical installer. Docker Engine, CLI client, Compose, Kitematic and Docker Machine, provided for installation.

    1. Download Docker from install docker desktop. You will get a .dmg file  

    2. Click on the .dmg file and it will ask you to move the Docker app to the Application Folder.

    3. Once the Docker icon has been dragged to the Applications folder, double-click the Docker icon and you will be asked if you want to open the App. Click on yes, to open Docker installer.

    4. Click on the Next button and after this, it will ask you to install tools and will ask your permissions to proceed:

    5. Now, you will see the Docker icon on the toolbar, which means that Docker is starting on your system.

    Step 2: Run the Jenkins Docker image

    After installation and set-up of Docker, you can run the following command to install Jenkins for mac:

    $ docker run -p 8080:8080 -p 50000:50000 -v ~/jenkins_home:/var/jenkins_home jenkins/jenkins:lts

    This command will download Jenkins' current version of Long-Term Support (LTS) and spin a new Docker container. This might take time for installation.

    Step 3: Get the installation password

    You will be asked for the administrator password and you will also see the location where you can find it when you visit Jenkins on its default 8080 port with your server domain name or IP address: http://localhost:8080/

    We can refer to the steps above for the location of the password.

    How to Configure Jenkins on Mac?

    After the installation of Jenkins, we have to configure Jenkins to make it ready.

    Step 1: Install Plugins

    Jenkins has many plugins that can integrate with open-source project. The next move requires the installation of suitable plugins as per your requirement.  You can easily add or delete plugins later.  As of now we can simply install the suggested plugins.

    Jenkins is currently the leading open-source automation server for all types of development work with around 1600 plugins. These 1,600 plug-ins cover five fields: platforms, UI management, management of source code, and build management most commonly.

    Now, you have to create an admin user account. Make sure you note down the username and password as they would be needed later.

    Step 2: Jenkins URL Configuration

    The last step is to configure the URL for the server.

    Click Save and Finish once you have confirmed the relevant information. A confirmation page will show you that "Jenkins is ready!"

    Finally, click on Start using Jenkins and you will see a dashboard.

    How to Start and Stop Jenkins?

    A. When you install Jenkins using Homebrew

    Run the following command to stop the Jenkins server:

    $ brew services stop jenkins-lts

    Run the following command to restart the server again:

    $ brew services restart jenkins-lts

    B. When you install Jenkins using Docker

    To stop Jenkins, go to the terminal window where the Docker container was started and enter command + C. This will stop the Docker container from running and also stop Jenkins.

    If you need to restart Jenkins, execute the same command that you used while installing Jenkins.

    How to Uninstall Jenkins on Mac?

    Jenkins is an automation platform focused on servers and is usually concerned with security. Jenkins also requires add-ons for projects written in languages other than Java. These additional components normally bloat Jenkins. Follow the steps to see how to uninstall Jenkins on Mac when you're having trouble or notice that Jenkins doesn't work on Mac.

    If you have installed Jenkins using Homebrew then you should run the following commands to uninstall Jenkins:

    $ brew uninstall jenkins --force
    $ brew cleanup

    Learn more about the core concepts of Jenkins Jobs, Pipelines, Distributed System, Plugins with Jenkins Certification Course.

    Why Use Jenkins?

    To understand Jenkins, you will need to consider continuous integration (CI) and continuous delivery (CD):

    • Continuous integration: the practice of continually merging the working copies of developers with the main repository.
    • Continuous delivery: constantly delivering the code to an area once it is ready for delivery. It could be for production or staging. The commodity is supplied to a consumer base that can provide QA or inspection by customers.

    Developers update the code regularly in the shared repository (such as GitHub or TFS). Improvements made in the source code are made at the end of the day together, making it difficult to identify the errors. To avoid this, Jenkins is used here.

    Once a developer changes the repository, Jenkins will automatically enable the build and immediately warn you in the event of an error (Continuous Integration CI).

    We can also automate the post-construction tests with Jenkins (unit test, success test, acceptance test). Jenkins will conduct these tests and produce a report whenever progress is achieved (Continuous Delivery CD).

    Conclusion

    Installing Jenkins on mac is very easy. Jenkins has a low learning curve and you can start to work with it as quickly as possible. There are some popular alternatives to Jenkins. One of these tools is Zuul, which does not allow broken code to integrate into your main branch, with various gate configurations like inter-project testing, cross-project dependencies and testing in parallel.

    In this tutorial, you have learnt to install Jenkins on macOS using the packages provided by the project. You have started the server, opened the firewall, and created an administrative user. Also, remember to continuously learn fundamentals by enrolling in a good course. My preferred course is the KnowldgeHut DeveOps Foundation course, where you’ll learn everything from scratch. Once you get started, you can become the holder of a highly effective automation mechanism that allows for code construction, testing, and launching.

    Frequently Asked Questions (FAQs)

    1Do I need to have Java installed to run Jenkins on Mac?

    To start using Jenkins on your Mac, you must install Java. I have explained above the essential steps that you can take if you want to install Java. 

    2How do I secure Jenkins after installation?

    For any non-local (test) Jenkins environment, there is a need to enable the “Enable Security” checkbox permanently. A Jenkins administrator can turn on or off some critical security features in the “Security” section of the web UI, and they will affect security in the whole Jenkins environment. This will ensure that your Jenkins is secured after installation. 

    3Where can I find the Jenkins home directory on Mac?

    All Jenkins-based installations are kept in Jenkins home directory, such as configurations, build logs, and artifacts. On Mac, the default home directory of Jenkins’s home is ~/.jenkins. install jenkins on mac  

    To find the Jenkins home directory, you can 

    • Open your browser and go to your Jenkins dashboard. 
    • Navigate to Management Jenkins >System. 
    • Search for the Jenkins home directory under Home. 
    Profile

    Mayank Modi

    Blog Author

    Mayank Modi is a Red Hat Certified Architect with expertise in DevOps and Hybrid Cloud solutions. With a passion for technology and a keen interest in Linux/Unix systems, CISCO, and Network Security, Mayank has established himself as a skilled professional in the industry. As a DevOps and Corporate trainer, he has been instrumental in providing training and guidance to individuals and organizations. With over eight years of experience, Mayank is dedicated to achieving success both personally and professionally, making significant contributions to the field of technology.

    Share This Article
    Ready to Master the Skills that Drive Your Career?

    Avail your free 1:1 mentorship session.

    Select
    Your Message (Optional)

    Upcoming DevOps Batches & Dates

    NameDateFeeKnow more
    Course advisor icon
    Course Advisor
    Whatsapp/Chat icon