Jenkins Download Mac

Posted on  by 

You may be working on a personal project. Maybe your company has a different CI/CD system from what you are used to or it’s hard to be onboarded with the CI/CD system. I’ve come up with a way to create your own personal Jenkins server and agent all in one macOS. The following diagram shows what I am envisioning.

This whole things can easily fit on a laptop or a desktop. Obviously the architecture could be applied to Windows and Linux as well. I have Mac as my main development machine, so I will use Mac as an example here.

Install Docker on Mac

Hey guys, in this post will learn about how to download and install Jenkins on Mac. Jenkins is a self-contained, open-source automation server that can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software. In this tutorial, we will see how to install Jenkins on Mac OS X. Step 1:Open browser and enter URL Step 2:Scroll down the page until you see the Mac OS X section then click on it.This will start the download for a Mac installation package. Once the download is complete, click on the package to start the installation. Jenkins can be installed using the Homebrew package manager. Homebrew formula: jenkins This is a package supported by a third party which may be not as frequently updated as packages supported by the Jenkins project directly. Sample commands: Install the latest Weekly version: brew install jenkins.

Installing Docker on macOS is very easy.

  • First, download Docker for Mac from here.
  • (Double-)click the downloaded Docker.dmg file.
  • Drag and drop the Docker application file to /Applications directory.
  • Double-click Docker.app file in /Applications directory.
  • You may have to reboot your machine to get the daemon to work correctly.
  • Open Terminal.
  • Execute docker run -d -p 80:80 docker/getting-started
  • Once it’s successful, it means your Docker installation was successful.

One thing to note is that you don’t have to add your account to docker group so you don’t have to sudo for every docker command to execute and docker-compose is bundled with Docker.app on Mac, which is nicer than the installation process on Linux.

Jenkins Master

We will spin up the Jenkins master using docker-compose. Create a directory such as ~/jenkins.

Copy and paste the following contents in docker-compose.yaml file in ~/jenkins.

Execute the following command to create a network for your Docker containers.

Jenkins Download For Mac

Jenkins Download Mac

After that, execute the following command from at ~/jenkins

When you see the output like the following, you have Jenkins up and running

At this point, you could hit the Jenkins master by navigating your browser to http://localhost:8080 but this is not what I want. I would like to have Dockerized NGINX in front of it and route the traffic to the Jenkins so that it is easy to implement SSL certs for it.

You can Ctrl+C to stop Jenkins and then…

to completely remove the container.

NGINX as Reverse Proxy

As the diagram indicates, my plan is to have NGINX accept HTTP(S) traffic and route the traffic to the Jenkins instance via the Docker’s virtual network.

Please follow the steps below.

Create a directory like ~/nginx

Copy and paste the following YAML to ~/nginx/docker-compose.yaml file and save the file.

Next, create ~/nginx/data directory. While you are there, let’s create conf.d directory.

Copy and paste the following contents to ~/nginx/data/nginx.conf file and save it.

Next, paste the following configuration to ~/nginx/conf.d/ssl.conf file.

SSL Support

Since I’m just planning to run this locally, there isn’t a need for SSL but I would like to implement this for a good practice. And you never know, you may want to create a Jenkins instance in a real environment eventually.

I am planning to make the URL https://jenkins.local

Place the following files for SSL support. If you need to know how to create self-signed cert, please take a look my previous article.

Jenkins For Windows

To summarize, here are the files you have to create for NGINX to work in the nginx root directory.

Next, let’s edit /etc/hosts file so that https://jenkins.local will resolve to your local NGINX.

Add the following line in the file.

Now navigate to ~/jenkins and execute the following command.

This starts the instance of Jenkins. Now navigate to ~/nginx and execute the following command.

This starts the instance of NGINX as a reverse proxy that routes the traffic to the containerized Jenkins.

Access Jenkins UI and Initial Configuration

If you open your browser, and navigate it to https://jenkins.local/ you should see the following screen.

Beware that if you try to get the Administrator password from /var/jenkins_home/secrets/initialAdminPassword, your host side does not have the file at that location. Instead, you should cat the file at the following location.

Once you get the admin password from the location, enter it to pass the initial screen to start the containerized Jenkins master.

Connect Jenkins Slave

If you take a look at the UI, you see that the Jenkins master has 2 executors by default. If you want your Mac to run builds, you can do so. Here are the steps.

Navigate to Manage Jenkins -> Manage Nodes and Clouds and then click New Node.

Enter mac for Node name and click Permanent Agent and then click OK.

And click Save on the next screen.

When you go back to Manage Nodes and Clouds, you will see the following screen.

Click mac (or whatever you created) and you will see the following screen.

You can definitely follow the instruction on the screen to connect your mac as a Jenkins slave. First download the agent.jar file from the same page and store it in ~/jenkins-slave directory.

Next execute the following command.

This writes the secret to the secret-file in the directory. And then try to execute the following command to get your mac connected to Jenkins master as a slave.

You would expect that this should be the last step but you would get an error like the following.

This means that Java does not trust the self signed SSL certificate you created. I blogged about this in the past, so please refer to this blog article to resolve this issue.

Once the SSL cert issue is resolved, it connects to Jenkins master and it’s ready like the image below.

Recap

It took me a few nights to write up this article. To recap…

  • Dockerizing Jenkins master
  • Using NGINX as a reverse proxy
  • Implementing SSL cert
  • Jenkins slave

Mac Jenkins Start

This give you an environment where you can manage your own Jenkins in Docker and do whatever you want!

Related

Homebrew Installer

Jenkins can be installed using theHomebrewpackage manager.Homebrew formula:jenkins-ltsThis is a package supported by a third party which may be not as frequently updated as packages supported by the Jenkins project directly.

Sample commands:
  • Install the latest LTS version:brew install jenkins-lts
  • Install a specific LTS version:brew install jenkins-lts@YOUR_VERSION
  • Start the Jenkins service:brew services start jenkins-lts
  • Restart the Jenkins service:brew services restart jenkins-lts
  • Update the Jenkins version:brew upgrade jenkins-lts
After starting the Jenkins service, browse to http://localhost:8080 and follow the instructions to complete the installation.Also see the external materials for installation guidelines. For example,this blogpostdescribes the installation process.

Native Installer (deprecated)

Jenkins Download Mac

Jenkins project used to provide a native installer for macOS.This installer is now deprecated, and it will not be shipped for future versions of Jenkins.It is possible to retrieve installer versions for older releases from the archive.

Coments are closed