Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Operations 10 min read

Guide to Installing and Configuring Jenkins CI on macOS

This tutorial explains how to install Jenkins on macOS using Homebrew, configure it as a launch agent, adjust JVM memory and garbage‑collection settings, set HTTP proxy, customize ports and prefixes, and create a complete launchd plist for a reliable 24/7 CI server.

Installation

To install Jenkins on a Mac, first ensure JDK is installed and then run the Homebrew command: brew install jenkins The package is placed under /usr/local. Homebrew provides instructions to create a launch agent:

ln -sfv /usr/local/opt/jenkins/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist

Instead of symlinking the plist, copy it to avoid losing changes after Homebrew upgrades. Pin the formula to prevent automatic upgrades: brew pin jenkins You can start and stop Jenkins manually:

# Start.
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist

# Stop.
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist

Configuration

Running the server reveals memory‑related errors; adjust the JVM options in the launchd plist. Set a 64‑bit model, initial and maximum heap size, and enable a concurrent garbage collector.

<string>-d64</string>
<string>-Xms512m</string>
<string>-Xmx512m</string>
<string>-XX:+UseConcMarkSweepGC</string>
<string>-XX:+CMSClassUnloadingEnabled</string>
<string>-XX:MaxPermSize=256m</string>

HTTP Proxy

If a corporate proxy is required, add the proxy host and port options:

<string>-Dhttp.proxyHost=my-company-proxy-host.com.au</string>
<string>-Dhttp.proxyPort=8080</string>

Port and Prefix

Run Jenkins on a custom port (default 8080) with a URL prefix such as /jenkins. These arguments are passed to jenkins.war located in /usr/local/opt/jenkins/libexec:

<string>-jar</string>
<string>/usr/local/opt/jenkins/libexec/jenkins.war</string>
<string>--httpListenAddress=127.0.0.1</string>
<string>--httpPort=8080</string>
<string>--prefix=/jenkins</string>

Run at Load

Enable automatic start after reboot by setting RunAtLoad to true in the plist:

<key>RunAtLoad</key>
<true/>

Environment Variables

Define any required environment variables, for example the HTTP proxy:

<key>EnvironmentVariables</key>
<dict>
  <key>HTTP_PROXY</key>
  <string>http://my-company-proxy-host.com.au:8080</string>
</dict>

Standard Output and Error

Redirecting stdout/stderr is optional; the author advises against redirecting stderr to a file due to large log growth.

<!--
  <key>StandardOutPath</key>
  <string>/Users/i4niac/.jenkins/log/output.log</string>
  -->
  <key>StandardErrorPath</key>
  <string>/Users/i4niac/.jenkins/log/error.log</string>

Jenkins stores its files under the .jenkins directory in the user’s home folder; ensure a log subdirectory exists.

Full Configuration

The complete launchd plist combines all the above settings:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>homebrew.mxcl.jenkins</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/bin/java</string>
    <string>-server</string>
    <string>-d64</string>
    <string>-Xms512m</string>
    <string>-Xmx512m</string>
    <string>-Dmail.smtp.starttls.enable=true</string>
    <string>-XX:+UseConcMarkSweepGC</string>
    <string>-XX:+CMSClassUnloadingEnabled</string>
    <string>-XX:MaxPermSize=256m</string>
    <string>-Djava.net.preferIPv4Stack=true</string>
    <string>-Dhttp.proxyHost=my-company-proxy-host.com.au</string>
    <string>-Dhttp.proxyPort=8080</string>
    <string>-jar</string>
    <string>/usr/local/opt/jenkins/libexec/jenkins.war</string>
    <string>--httpListenAddress=127.0.0.1</string>
    <string>--httpPort=8080</string>
    <string>--prefix=/jenkins</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>EnvironmentVariables</key>
  <dict>
    <key>HTTP_PROXY</key>
    <string>http://my-company-proxy-host.com.au:8080</string>
  </dict>
</dict>
</plist>

With this configuration, Jenkins runs continuously and can reliably execute CI jobs.

Tips

To verify how Jenkins was started, inspect the process list: ps aux | grep java The output shows the Java command line with all JVM options and the path to jenkins.war. After installation, further steps such as installing plugins, configuring SSH keys for Git, and other management tasks are required to fully operationalize the CI server.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

DevOpsmacOSCIJenkinsHomebrew

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion