macOSにGitLab Runnerをインストールする
- プラン: Free、Premium、Ultimate
- 提供形態: GitLab.com、GitLab Self-Managed、GitLab Dedicated
AppleシリコンまたはIntel x86-64システムにmacOS用GitLab Runnerをインストールします。GitLab自体は、通常、ローカルまたはリモートのコンテナまたは仮想マシンで実行されます。
macOSサービスモード
macOSでは、GitLab RunnerはシステムレベルのLaunchDaemonではなく、ユーザーモードのLaunchAgentとして実行されます。これが唯一サポートされているモードです。
ユーザーモードでは、Runnerは次のようになります:
- 現在の認証済みユーザーとして実行され、rootとしては実行されません。
- そのユーザーがサインインしたときに開始し、サインアウトしたときに停止します。
- ユーザーのキーチェーンとUIセッションにアクセスできます。これは、iOSシミュレーターを実行し、コード署名を実行するために必要です。
- 設定を
~/.gitlab-runner/config.tomlに保存します。
システムレベルのLaunchDaemonは、起動時にrootとして実行され、ユーザーセッションにアクセスできません。GitLab Runnerは、LaunchDaemonとしての実行をサポートしていません。
再起動後もRunnerを利用できるようにするには、macOSマシンで自動ログインをオンにしてください。
GitLab Runnerをインストールする
Apple SiliconまたはIntel x86-64システムでCI/CDのジョブを実行するために、macOSにGitLab Runnerをインストールします。
前提条件:
- ジョブを実行するユーザーアカウントとしてmacOSマシンにサインインしている必要があります。この手順ではSSHセッションを使用しないでください。ローカルGUIターミナルを使用してください。
GitLab Runnerをインストールするには、次の手順に従います:
ご使用のシステムに対応するバイナリをダウンロードします。
Intel (x86-64)の場合:
sudo curl --output /usr/local/bin/gitlab-runner \ "https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-darwin-amd64"Apple Siliconの場合:
sudo curl --output /usr/local/bin/gitlab-runner \ "https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-darwin-arm64"
特定のタグ付きリリースのバイナリをダウンロードするには、他のタグ付きリリースをダウンロードを参照してください。
バイナリを実行可能にします:
sudo chmod +x /usr/local/bin/gitlab-runnerRunner設定を登録します。iOSおよびmacOSのビルドには、Shell executorを使用してください。セキュリティの詳細については、Shell executorのセキュリティを参照してください。
GitLab Runnerサービスをインストールして開始します:
cd ~ gitlab-runner install gitlab-runner startシステムを再起動します。
gitlab-runner installコマンドは、~/Library/LaunchAgents/gitlab-runner.plistにLaunchAgent plistを作成し、launchctlに登録します。エラーが発生した場合は、トラブルシューティングを参照してください。
設定ファイルの場所
| ファイル | パス |
|---|---|
| 設定 | ~/.gitlab-runner/config.toml |
LaunchAgent plist | ~/Library/LaunchAgents/gitlab-runner.plist |
| 標準出力ログ | ~/Library/Logs/gitlab-runner.out.log |
| 標準エラーログ | ~/Library/Logs/gitlab-runner.err.log |
設定オプションの詳細については、高度な設定を参照してください。
GitLab Runnerをアップグレードする
GitLab Runnerを新しいバージョンにアップグレードするには:
サービスを停止します。
gitlab-runner stopバイナリをダウンロードして、GitLab Runner実行可能ファイルを置き換えます。
Intel (x86-64)の場合:
sudo curl -o /usr/local/bin/gitlab-runner \ "https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-darwin-amd64"Apple Siliconの場合:
sudo curl -o /usr/local/bin/gitlab-runner \ "https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-darwin-arm64"
特定のタグ付きリリースのバイナリをダウンロードするには、他のタグ付きリリースをダウンロードを参照してください。
バイナリを実行可能にします:
sudo chmod +x /usr/local/bin/gitlab-runnerサービスを開始します:
gitlab-runner start
サービスファイルをアップグレードする
LaunchAgentの設定をアップグレードするには、サービスをアンインストールして再インストールします:
gitlab-runner uninstall
gitlab-runner install
gitlab-runner startGitLab Runnerでcodesignを使用する
HomebrewでGitLab Runnerをインストールし、ビルドがcodesignを呼び出す場合、ユーザーキーチェーンにアクセスするために<key>SessionCreate</key><true/>を設定する必要があるかもしれません。
GitLabはHomebrewのフォーミュラを保守していません。公式バイナリを使用してGitLab Runnerをインストールしてください。
以下の例では、Runnerはgitlabユーザーとしてビルドを実行し、そのユーザーの署名証明書にアクセスする必要があります:
<?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>SessionCreate</key><true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>RunAtLoad</key><true/>
<key>Disabled</key><false/>
<key>Label</key>
<string>com.gitlab.gitlab-runner</string>
<key>UserName</key>
<string>gitlab</string>
<key>GroupName</key>
<string>staff</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/gitlab-runner/bin/gitlab-runner</string>
<string>run</string>
<string>--working-directory</string>
<string>/Users/gitlab/gitlab-runner</string>
<string>--config</string>
<string>/Users/gitlab/gitlab-runner/config.toml</string>
<string>--service</string>
<string>gitlab-runner</string>
<string>--syslog</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
</dict>
</plist>トラブルシューティング
macOSにGitLab Runnerをインストールする際に、以下のイシューに遭遇する可能性があります。
一般的なトラブルシューティングについては、GitLab Runnerのトラブルシューティングを参照してください。
エラー: killed: 9
Apple Siliconでは、gitlab-runner install、gitlab-runner start、またはgitlab-runner registerコマンドを実行すると、このエラーが発生する可能性があります。
このエラーを解決するには、~/Library/LaunchAgents/gitlab-runner.plistにあるStandardOutPathとStandardErrorPathのディレクトリが存在し、書き込み可能であることを確認してください。例:
<key>StandardErrorPath</key>
<string>/Users/<username>/gitlab-runner-log/gitlab-runner.err.log</string>
<key>StandardOutPath</key>
<string>/Users/<username>/gitlab-runner-log/gitlab-runner.out.log</string>エラー: "launchctl" failed: Could not find domain for
このエラーは、ローカルGUIターミナルの代わりにSSH経由でGitLab Runnerサービスを管理するときに発生します。
このエラーを解決するには、macOSマシンでターミナルアプリケーションを直接開き、そこからinstallとstartコマンドを実行してください。
エラー: Failed to authorize rights (0x1) with status: -60007
このエラーには2つの原因が考えられます。
あなたのユーザーアカウントには開発者ツールへのアクセス権がありません。アクセスを許可するには:
DevToolsSecurity -enable
sudo security authorizationdb remove system.privilege.taskport is-developerまたは、LaunchAgent plistのSessionCreateがtrueに設定されています。このイシューを修正するには、サービスを再インストールしてください:
gitlab-runner uninstall
gitlab-runner install
gitlab-runner start~/Library/LaunchAgents/gitlab-runner.plistのSessionCreateがfalseに設定されていることを確認してください。
エラー: Failed to connect to path port 3000: Operation timed out
RunnerがあなたのGitLabインスタンスに到達できません。接続をブロックしている可能性のあるファイアウォール、プロキシ、ルーティング設定、または権限のイシューを確認してください。
エラー: FATAL: Failed to start gitlab-runner: exit status 134
このエラーは、GitLab Runnerサービスが正しくインストールされていないことを示しています。
このエラーを解決するには、サービスを再インストールしてください:
gitlab-runner uninstall
gitlab-runner install
gitlab-runner startエラーが解決しない場合は、SSHを使用する代わりにmacOS GUIデスクトップにサインインし、そこからターミナルでコマンドを実行してください。LaunchAgentは、ブートストラップのためにグラフィカルなログインセッションを必要とします。
AWS上のmacOSインスタンスの場合、GUIに接続するためにAWSのドキュメントに従い、そのセッションのターミナルから再試行してください。
エラー: launchctl failed: Load failed: 5: Input/output error
gitlab-runner startコマンドの実行時にこのエラーが発生した場合は、まず、Runnerがすでに実行中かどうかを確認してください:
gitlab-runner statusRunnerが実行されていない場合は、~/Library/LaunchAgents/gitlab-runner.plistにあるStandardOutPathとStandardErrorPathのディレクトリが存在し、Runnerのユーザーアカウントがそれらへの読み取り/書き込みアクセス権を持っていることを確認してください。次に、Runnerを起動します:
gitlab-runner startエラー: couldn't build CA Chain
このエラーは、GitLab Runner v15.5.0にアップグレードした後に発生する可能性があります。完全なエラーメッセージは次のとおりです:
ERROR: Error on fetching TLS Data from API response... error error=couldn't build CA Chain:
error while fetching certificates from TLS ConnectionState: error while fetching certificates
into the CA Chain: couldn't resolve certificates chain from the leaf certificate: error while
resolving certificates chain with verification: error while verifying last certificate from
the chain: x509: "Baltimore CyberTrust Root" certificate is not permitted for this usage
runner=x7kDEc9Qこのエラーを解決するには:
GitLab Runner v15.5.1以降にアップグレードします。
アップグレードできない場合は、
[runners.feature_flags]の設定でFF_RESOLVE_FULL_TLS_CHAINをfalseに設定します:[[runners]] name = "example-runner" url = "https://gitlab.com/" token = "TOKEN" executor = "docker" [runners.feature_flags] FF_RESOLVE_FULL_TLS_CHAIN = false
Homebrew Git認証情報ヘルパーによりフェッチがハングする
HomebrewがGitをインストールした場合、/usr/local/etc/gitconfigにcredential.helper = osxkeychainエントリが追加されている可能性があります。これはmacOSキーチェーンに認証情報をキャッシュし、git fetchがハングする原因となることがあります。
認証情報ヘルパーをシステム全体から削除するには:
git config --system --unset credential.helperGitLab Runnerユーザーのみに無効にするには:
git config --global --add credential.helper ''現在の設定を確認するには:
git config credential.helper