JetBrains Space Help

Configure Remote Build Cache Storage

You can use a file repository in Space as a build cache storage for your projects. The purpose of such a remote storage is to serve as a shared cache for build artifacts across your team. This can make the build process faster, more consistent across different machines, and more efficient in terms of resource usage. It is especially useful for larger projects with many dependencies.

Basically, a file repository in Space can be used by any build tool that supports the WebDAV protocol. However, this topic provides instructions only for Gradle and Bazel as the most popular build tools.

Remote build cache for Gradle projects

  1. Create a file repository in Space.

  2. On the file repository page, click Get started.

  3. Under Tool, choose either Gradle Build Cache (Groovy) or Gradle Build Cache (Kotlin) depending on which Gradle DSL you use in your project.

  4. Unfold Generate read token and choose Write token. Click Generate write token and copy the snippet shown on the page to the clipboard.

  5. In your project, depending on the Gradle DSL, open the settings.gradle or settings.gradle.kts file.

  6. Paste the snippet to the file. For example:

    buildCache { remote<HttpBuildCache> { url = uri("https://files.pkg.jetbrains.space/mycompany/p/my-project/cache") // better make it a variable and set it to true only for CI builds isPush = true credentials { username = "John.Doe" password = "here-goes-the-generated-token" } } }
    buildCache { remote(HttpBuildCache) { url = 'https://files.pkg.jetbrains.space/mycompany/p/my-project/cache' // better make it a variable and set it to true only for CI builds setPush(true) credentials { username = 'John.Doe' password = 'here-goes-the-generated-token' } } }

    Learn more

  7. By default, using build cache is disabled in Gradle. To use the remote cache, you should either run your builds with the --build-cache argument or enable it permanently by adding the following line to the gradle.properties file:

    org.gradle.caching=true

    Learn more

Remote build cache for Bazel projects

  1. Create a file repository in Space.

  2. On the file repository page, click Get started.

  3. Under Tool, choose Bazel Remote Cache.

  4. Unfold Generate read token and choose Write token. Click Generate write token and copy the snippet shown on the page to the clipboard.

  5. On your local machine, open the .bazelrc file and add the remote cache settings to it. For example:

    build --remote_cache=https://files.pkg.jetbrains.space/mycompany/p/my-project/cache build --remote_header=Authorization="Bearer here-goes-the-generated-token"

    After this, the bazel build command will use the remote cache by default. The best practice though is using a CI/CD server to create and upload cache data to the remote storage. This helps to avoid potential problems from differences in local setups. Developer machines should then use the remote cache in the read-only mode:

    bazel build --remote_upload_local_results=false

    Learn more about Bazel remote caching

Remote build cache using sccache

sccache is a caching tool for C/C++, Rust, and other languages. Note that remote cache is supported only by sccache version 0.54 or later. Learn more

  1. Create a file repository in Space.

  2. On the file repository page, click Get started.

  3. Under Tool, choose sccache Remote Cache.

  4. Unfold Generate read token and choose Write token. Click Generate write token and copy the snippet shown on the page to the clipboard.

  5. On your local machine, provide the remote cache settings as sccache environment variables. To do this, run:

    export SCCACHE_WEBDAV_ENDPOINT="https://files.pkg.jetbrains.space/mycompany/p/my-project/cache" export SCCACHE_WEBDAV_TOKEN="here-goes-the-generated-token"

    After this, you can run your builds as usual, for example: cargo build. Your build tool will use the remote cache by default.

Last modified: 05 July 2023