Skip to main content

他の CI 環境での Gradle のリモート キャッシュの構成

Bitrise Build Cache では Bitrise CI を使用する必要はありません。他の CI/CD サービスを使用しても、リモート キャッシュを活用して Gradle のビルド時間を短縮できます。

これを行うには、ビルド中に Bitrise Build Cache CLI をダウンロードし、CLI を実行して Bitrise Build Cache を有効にするように CI 環境を構成する必要があります。

  1. Select your Bitrise workspace and go to Build Cache.

  2. Click New connection.

  3. Select Other CI provider and then select your build tool from the dropdown menu.

    2025-10-21-choose-build-tool.png
  4. Click Create token.

    2025-10-21-create-token.png
  5. Enter a name and set it to never expire.

  6. Copy the variables and add them to your CI configuration as Environment Variables.

  7. 高速化するステップの前に、次のスクリプトを CI 構成に追加します。

    環境

    高速化したい Gradle コマンドと同じ環境でスクリプトを実行してください。たとえば、ビルド全体で複数の Docker コンテナを使用する場合は、Bitrise Build Cache CLI が Gradle コマンドと同じ Docker コンテナで実行されていることを確認してください。

    #!/usr/bin/env bash
    set -euxo pipefail
    
    # download Bitrise Build Cache CLI
    curl -sSfL 'https://raw.githubusercontent.com/bitrise-io/bitrise-build-cache-cli/main/install/installer.sh' | sh -s -- -b /tmp/bin -d
    
    # run the CLI to enable Bitrise build cache for Gradle
    /tmp/bin/bitrise-build-cache activate gradle --cache --cache-push