For enquiries call:

Phone

+1-469-442-0620

April flash sale-mobile

HomeBlogDevOpsHow to install Jenkins on a Mac [Step-By-Step Tutorial]

How to install Jenkins on a Mac [Step-By-Step Tutorial]

Published
05th Sep, 2023
Views
view count loader
Read it in
8 Mins
In this article
    How to install Jenkins on a Mac [Step-By-Step Tutorial]

    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 your 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

    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).

    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

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

    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 

    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

    Installation Procedure

    We will discuss two ways to install Jenkins on your macOS:

    • Using Homebrew package
    • Using Docker

    Install Jenkins 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 process at the end in the section How to configure Jenkins?

    Install Jenkins using Docker

    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:

    $ 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?

    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 3: 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?

    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

    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.

    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 using the packages provided by the project. You have started the server, opened the firewall, and created an administrative user. You can now begin to explore Jenkins!

    Profile

    KnowledgeHut .

    Author

    KnowledgeHut is an outcome-focused global ed-tech company. We help organizations and professionals unlock excellence through skills development. We offer training solutions under the people and process, data science, full-stack development, cybersecurity, future technologies and digital transformation verticals.

    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