跪拜 Guibai
← All articles
Frontend

Apple Silicon iOS CI with Jenkins and Fastlane: The PollSCM 'H/1' Trap That Silently Stalls Builds

By Yannik ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The `H/1 * * * *` cron shorthand silently means once per hour rather than every minute, so any Jenkins job using it will stall for a full hour; the guide's diagnostic method works on any Jenkins instance. More broadly, it proves a single Mac can run a complete iOS CI chain locally, and its repo-centric Jenkinsfile design makes moving to a cloud scheduler plus inbound Mac agent a config change, not a rewrite.

Summary

This guide walks through a full iOS CI build on an Apple Silicon Mac, using a local Jenkins instance and Fastlane, with no public server—pure polling. Pushes to develop trigger automatic packaging within a minute, and each feature branch gets its own multibranch job that runs SwiftLint and a simulator compile, so MRs only merge when the branch is green.

The practical value is in the pitfalls. Jenkins LTS now demands JDK 21, Homebrew's bottles break on macOS 26 due to sandbox-exec removal, and the brew fastlane package is missing gems—you must install via gem. The article also details how to handwrite launchd plists to avoid brew services losing logs, fix plugin installs via offline hpi files, and unlock keychains for background Jenkins sessions.

The single biggest trap is `pollSCM('H/1 * * * *')`. The H/1 syntax in Jenkins cron means "one hash-chosen minute per hour," not every minute. The article shows a diagnostic path that ends in decompiling `Trigger.class` and checking the CronTab's minute bit count to prove the schedule. The fix is using `'* * * * *'` for true minute polling. It also covers migrating to cloud Jenkins with the Mac as an inbound JNLP agent, which naturally passes NAT and enables Gitee Webhook event triggering instead of polling.

Takeaways
— Jenkins LTS now requires JDK 21; openjdk@21 is keg-only and `JAVA_HOME` must be exported manually.
— Homebrew 7 bottles fail to extract on macOS 26 because `sandbox-exec` is deprecated; verify with `/usr/bin/sandbox-exec -p '(version 1)(allow default)' echo` and use pkg installers as a workaround.
— Brew's fastlane is broken; install via `gem install fastlane` and symlink the whole bin directory, otherwise Jenkins reports `xcpretty: command not found`.
— Free Apple ID development builds expire after 7 days and are only for device debugging, not TestFlight distribution.
— Jenkins background sessions cannot access the login keychain; use a stored password with `security unlock-keychain` or a dedicated packaging keychain.
— New OpenSSH key files lack the `ENCRYPTED` header, so passphrase detection by grep fails, but non-interactive auth still fails; use `ssh-add --apple-use-keychain`.
— Initial plugin installs over the network often time out; offline install via Huawei cloud mirror hpi files is the reliable fix.
— `brew services restart` regenerates the plist and wipes manual changes, so write a custom launchd plist with log paths for debugging.
— `pollSCM('H/1 * * * *')` schedules one hash-based minute per hour, not every minute; use `'* * * * *'` for minute-level polling.
— For multibranch REST creation, use `WildcardSCMHeadFilterTrait` (in scm-api) and `PeriodicFolderTrigger` (in cloudbees-folder), and prefer script console over config.xml when POST fails.
— Cloud migration: Jenkins on Linux scheduler plus Mac as inbound JNLP agent bypasses NAT; Gitee Webhook then gives second-level event triggering instead of polling.
Conclusions

The H/1 cron trap is a generic Jenkins hazard: hash-based cron spec actively hides the real schedule, and the only reliable way to catch it is decompiling the core and inspecting internal scheduling queues.

Polling-based CI on a local Mac is a workable stopgap for small teams, but webhook event triggering is strictly better; the article's repo-stored Jenkinsfile is what makes that switch nearly free.

Keeping the entire pipeline definition in the repository, as this setup does, turns a migration from local to cloud into a config exercise rather than a code rewrite, which is the real architectural lesson.

Concepts & terms
pollSCM
A Jenkins trigger that periodically checks the source control for changes using a cron-like schedule. The 'H' character in the spec means 'hash of the job name' to spread load, which changes the effective schedule.
H/1 cron syntax
In Jenkins cron, `H/1 * * * *` slices the hour into one slot and picks a hash-determined minute, so it runs exactly once per hour, not every minute. For every-minute polling you must write `* * * * *`.
Inbound agent (JNLP)
A Jenkins agent that initiates a connection to the controller, rather than the controller connecting to the agent. This lets build machines sit behind NAT or firewalls with no inbound ports open.
Multibranch pipeline
A Jenkins job type that discovers branches in a repository and automatically creates a sub-job for each branch, all using the same pipeline definition, with automatic cleanup when branches are deleted.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗