Start Building for Free
CircleCI.comアカデミーブログコミュニティサポート

クラウド上の CircleCI マシンランナーの更新

1 month ago1 min read
クラウド
このページの内容

ここでは、CircleCI クラウド 上で CircleCI マシンランナーを更新する方法を説明します。

現在のマシンランナーバージョンの確認

マシンランナーのバージョンは、バイナリに --version フラグを付けることで確認することができます。 CircleCI マシンランナー バイナリのデフォルトのインストールディレクトリは以下の通りです:

  • Linux と macOS: /opt/circleci/circleci-launch-agent

  • Windows: C:\Program Files\CircleCI\circleci-launch-agent.exe

自動更新の有効化方法

既存のCircleCIマシンランナーをアップグレードする最も簡単な方法は、設定ファイルで自動更新を有効にし、ランナーインスタンスを再起動することです。 自動更新を有効にするには、次の手順に従います:

  1. マシンランナー設定ファイルから disable_auto_update オプションを削除するか、 runner.disable_auto_updatefalse に設定してください。

  2. CircleCI マシンランナーエージェントを管理するために使用されるプロセス管理を使用して、マシンランナーインスタンスを再起動してください。 もしマシンランナーを管理するためにプロセス管理が使用されていない場合は、macOS や Linux システムでは kill -9 を使用してインスタンスを手動で停止し、 Windows システムではタスクマネージャーを使用して手動で再起動する必要があります。

マシンランナーの設定に関する詳細は、 マシンランナー設定リファレンスを参照してください。

Linux

sudo systemctl restart circleci.service

macOS

sudo launchctl stop '/Library/LaunchDaemons/com.circleci.runner.plist'
sudo launchctl start '/Library/LaunchDaemons/com.circleci.runner.plist'

Windows

Stop-ScheduledTask -TaskName "CircleCI Launch Agent"
Start ScheduledTask -TaskName "CircleCI Launch Agent"

マシンランナーバイナリの新バージョンダウンロードによる手動更新

自動更新が使用できないマシンランナーでは、ローンチエージェントバイナリ(launch-agent binary)として知られるマシンランナーバイナリを手動でダウンロードし、既存のバージョンを置き換えるために使用することができます。

バイナリをダウンロードするプロセスは、3つのステップに分かれています:バイナリのダウンロード、バイナリの置換、そしてCircleCIマシンランナーサービスの再起動です。 各ステップの詳細は次のセクションで説明します。

1. 新しいバージョンのバイナリをダウンロード

Linux または macOS のバイナリをダウンロードする

プラットフォーム環境変数を設定

Linux macOS のインストール作業と同様に、まず環境変数 platform を対象となるインストールシステムに対して正しい値に設定する必要があります。

# for Linux x86_64
export platform=linux/amd64
# for Linux ARM64
export platform=linux/arm64
# for Linux s390x
export platform=linux/s390x
# for Linux ppc64le
export platform=linux/ppc64le
# for macOS ARM64 (M1+ chips)
export platform=darwin/arm64
# for macOS x86_64
export platform=darwin/amd64
新エージェントバイナリのダウンロード
# Download the new version of the CircleCI Agent manually on macOS, and Linux with bash
base_url="https://circleci-binary-releases.s3.amazonaws.com/circleci-launch-agent"
agent_version=$(curl "${base_url}/release.txt")
curl -sSL "${base_url}/${agent_version}/checksums.txt" -o checksums.txt
mkdir -p "${platform}"
file="$(grep -F "${platform}" checksums.txt | cut -d ' ' -f 2 | sed 's/^.//')"
curl --compressed -L "${base_url}/${agent_version}/${file}" -o "${file}"
grep "${file}" checksums.txt | sha256sum --check || echo "Failed to download the CircleCI machine runner binary, please try again"
chmod +x $file

Windows のバイナリをダウンロードする

# Download the new version of the CircleCI Agent manually on Windows with PowerShell
$Env:platform = "windows/amd64"
mkdir $Env:platform
$Env:baseURL =  "https://circleci-binary-releases.s3.amazonaws.com/circleci-launch-agent"
$Env:agentVersion = $(curl "$Env:baseURL/release.txt")
$Env:agentVersion = "$Env:agentVersion".Trim()
curl "$Env:baseURL/$Env:agentVersion/checksums.txt" -o checksums.txt
$Env:fileName = $(Select-String $Env:platform checksums.txt | cut -d ' ' -f 2 | sed 's/^.//')
$Env:fileName = $Env:fileName.Trim()
curl "$Env:baseURL/$Env:agentVersion/$Env:fileName" -o $Env:fileName
$Env:fileHash = $(Get-FileHash $Env:fileName -Algorithm "SHA256" | select -expand "Hash")
$Env:expectedHash = "$(grep $Env:filename checksums.txt)".Split(" ")[0]
if ($Env:expectedHash -ne $Env:fileHash) { Write-Output "CircleCI machine runner binary download failed, please try again"}else{Write-Output "CircleCI machine runner binary successfully downloaded to $CWD/$Env:fileName"}

2. 既存のバイナリを新しいバージョンに置き換える

Linux で既存バイナリを置き換える

sudo systemctl stop circleci.service
# Replace the current binary with the newly downloaded binary, by default the machine runner binary is installed to `/opt/circleci/circleci-launch-agent`

macOS で既存バイナリを置き換える

sudo launchctl stop '/Library/LaunchDaemons/com.circleci.runner.plist'
# Replace the current binary with the newly downloaded binary, by default the machine runner binary is installed to `/opt/circleci/circleci-launch-agent`

Windows で既存バイナリを置き換える

Stop-ScheduledTask -TaskName "CircleCI Launch Agent"
# Replace the current binary with the newly downloaded binary, this will require renaming or deleting the existing binary

3. マシンランナーサービスを再起動する

Linux のマシンランナーサービスを再起動する

sudo systemctl start circleci.service

macOS のマシンランナーサービスを再起動する

sudo launchctl start '/Library/LaunchDaemons/com.circleci.runner.plist'

Windows のマシンランナーサービスを再起動する

Start-ScheduledTask -TaskName "CircleCI Launch Agent"

ドキュメントの改善にご協力ください

このガイドは、CircleCI の他のドキュメントと同様にオープンソースであり、 GitHub でご利用いただけます。 ご協力いただき、ありがとうございます。

サポートが必要ですか

CircleCI のサポートエンジニアによる、サービスに関する問題、請求およびアカウントについての質問への対応、設定の構築に関する問題解決のサポートを行っています。 サポートチケットを送信して、CircleCI のサポートエンジニアにお問い合わせください。日本語でお問い合わせいただけます。

または、 サポートサイト から、サポート記事やコミュニティフォーラム、トレーニングリソースをご覧いただけます。