Home/Guides/How to connect a remote Mac to Jenkins as an inbound build agent

How to connect a remote Mac to Jenkins as an inbound build agent

Updated · airankrush

What this guide covers

When you finish, Jenkins' node list has one more online macOS agent, and jobs with the matching label are sent to it. You need: administrator access to Jenkins, a controller address this Mac can reach, and Java on the Mac.

Steps

  1. Choose the connection direction first

    There are two ways to attach a Jenkins agent. In one, the controller starts the agent over SSH, which requires the controller to connect into this Mac. The only connection methods we provide are UU Remote and RustDesk, and whether Remote Login that you turn on yourself can be reached from the public internet depends on the delivery notes, so this route is usually not suitable.

    The other is what the Jenkins Remoting documentation calls agent-initiated: the agent connects to the controller first, and the controller then sends jobs as needed. This Mac only needs outbound access to your Jenkins, so choose this one.

  2. Prepare Java on the Mac

    The agent itself is a Java program. According to the Jenkins node management documentation, the agent machine needs a working Java; see the notes that document links to for version requirements. Install it with Homebrew or the vendor's installer, then confirm with java -version.

  3. Create the node on the controller

    In Jenkins' node management, create a new permanent node. The name is up to you. For the remote working directory, enter a path under your own user directory on this Mac. For labels, enter something like macos and ios; pipelines select the machine by them. For the launch method, choose the option for launching the agent by connecting it to the controller (the wording in the interface varies with the Jenkins version).

    After you save, the node page shows an agent launch command that includes a secret.

  4. Download agent.jar and start it

    According to the Remoting documentation, agent.jar is downloaded from your own Jenkins, at the Jenkins URL followed by /jnlpJars/agent.jar. The launch command has this form:

    java -jar agent.jar -url <Jenkins URL> -secret @secret-file -name <node name> -webSocket -workDir <working directory>

    The documentation explains that prefixing an argument with @ reads its content from that file, so the secret does not appear on the command line or in the process list. Save the secret from the node page in secret-file and tighten the file's permissions so only you can read it.

  5. Why add -webSocket

    Without it, the agent first contacts the controller's HTTP(S) port for connection information and then connects to a separate TCP port. According to Jenkins' exposed services documentation, that port is disabled by default in most installation packages.

    With WebSocket transport, the documentation states that no extra TCP port and no special security configuration is needed, only a single connection to the controller. In both modes the Mac connects outward, and nothing has to be opened to the outside on the Mac's side.

  6. Keep the agent running

    Once it works in the foreground, hand the command to launchd: put a property list file under ~/Library/LaunchAgents in your own user directory that specifies the command, KeepAlive and the log paths. See how to keep long tasks running for how to write it.

    The reason for a service under the logged-in user rather than a system-level service is that code signing needs the keychain and simulators need a graphical session. The cost is that it starts only after your account logs in: after the machine restarts, connect and log in once, then confirm in Jenkins that the node is online.

  7. Permission boundaries and ending the rental

    Jobs on the agent run as your macOS user and can read the certificates, keys and everything in the working directory. Let only pipelines you trust use this label.

    Before the rental ends: stop and unload this LaunchAgent, delete the node in Jenkins so the secret becomes invalid, and delete secret-file from the machine. Archive any build products in the working directory that you need to keep to Jenkins or your own storage first.

FAQ

The controller is on the company's internal network and the Mac cannot reach it. What can I do?

The agent must be able to reach the controller's address. The usual approach is to give Jenkins a protected external entry point on your own side. Do not install tunneling or mesh networking software on the rented Mac yourself for this; if you need it, check with Contact support first.

Why does the node show as offline?

Connect to the Mac and look at the agent process and logs. Common causes are that the account has not logged in yet after a restart, the secret was reset on the controller, or the controller address changed.

Can I install the Jenkins controller itself on this Mac?

Technically it can be installed, but a controller has to be reachable by the team and by the code hosting platform, and this machine does not offer ports mapped to the outside. It is better suited to being an agent only.

Can one Mac have more than one executor?

The number of executors can be changed in the node settings. Parallel iOS builds compete for CPU, memory and the derived data directory. Whether it pays off depends on your project; we have no measured figures to offer.

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · All guides