Configuring the Cloud Runner / Nx CLI

The Nx Cloud runner is set when you connect to Nx Cloud. Its configuration appears in nx.json and by default will look similar to this.

{ "tasksRunnerOptions": {   "default": {      "runner": "@nrwl/nx-cloud",        "options": {            "accessToken": "SOMETOKEN", "cacheableOperations": ["build", "test", "lint", "e2e"], } } }, }

Cacheable Operations

Only operations listed in cacheableOperations can be cached using Nx Cloud, and distributed using the distributed task execution. You can add new targets to that list.

Timeouts

By default, Nx Cloud requests will time out after 10 seconds. NX_CLOUD_NO_TIMEOUTS disables the timeout.

NX_CLOUD_NO_TIMEOUTS=true nx run-many --target=build --all

Logging

Setting NX_VERBOSE_LOGGING=true when running a command will emit a lot more metadata about the command. It will print information about what artifacts are being downloaded and uploaded, as well as information about the hashes of every computation. This can be useful for debugging unexpected cache misses.

This will also print detailed information about distributed task execution: what commands were sent where etc.

Usually, NX_VERBOSE_LOGGING is only enabled for troubleshooting purposes. It is often enabled in CI globally while debugging your CI setups.

Access Tokens

NX_CLOUD_AUTH_TOKEN and NX_CLOUD_ACCESS_TOKEN are aliases. It allows to override the access token set in nx.json. It's often enabled in CI to provide read-write privileges where only a read token is committed to the workspace's nx.json.

Enabling End-to-End Encryption

All communication with Nx Cloud’s API and cache is completed over HTTPS, but you can optionally enable e2e encryption by providing a secret key through nx.json or the NX_CLOUD_ENCRYPTION_KEY environment variable.

In nx.json, locate the taskRunnerOptions property. It will look something like this:

{ "tasksRunnerOptions": {   "default": {      "runner": "@nrwl/nx-cloud",        "options": {            "accessToken": "SOMETOKEN", "cacheableOperations": ["build", "test", "lint", "e2e"], // Add the following property with your secret key "encryptionKey": "cheddar" } } }, }

Under the options property, you can add an additional property called encryptionKey. This is what will be used to encrypt your artifacts.

To instead use an environment variable to provide your secret key, run any Nx command as follows:

NX_CLOUD_ENCRYPTION_KEY=myEncryptionKey nx build my-project

This is an alternative to providing the encryption key through nx.json, but functionally it is identical.

Select an article to learn more about Nx Cloud