JetBrains Space Help



  • You have a working Rust project.

  • (Optional) The project has unit tests.

  • If you want to build and publish a Cargo package to Space Packages, make sure that:

    • The corresponding Space project has a sparse Cargo registry.

    • The .cargo/config.toml file contains registry configuration. For example:

      [] index = "sparse+" credential-provider="cargo:token"

      Learn more

Eligible images

Build, run tests, and publish in a Rust project

Currently, Automation does not provide any API for working with Rust. So, the only way to build, test, and publish Rust projects is to use the cargo command-line tool in shell scripts.

The content of .space.kts might look like follows:

job("Build, run tests, and publish") { container(displayName = "Run script", image = "rustlang/rust:nightly") { shellScript { content = """ set -e # Build the Rust project cargo build --verbose # Run tests cargo test --verbose # Publish to sparse Cargo registry cargo login --registry=space-registry "Bearer ${'$'}JB_SPACE_CLIENT_TOKEN" cargo publish --verbose --registry=space-registry """ } } }

Here JB_SPACE_CLIENT_TOKEN is the environment variable that stores an authorization token. The token lets the Space Automation service to authorize in Space Packages.

Last modified: 15 December 2023