Skip to content

[rush] Specify environment variables for build cache #3730

@chengcyber

Description

@chengcyber

Summary

This is a feature request for build cache: support specifying a list of environment variable name, and take them into consideration when calculating cache id.

Details

This proposal wants to add a configuration to specify a list of environment variable name, and use them when calculating cache id.

Use case

Running CDN_PREFIX=/a/b rush build --to <app>, it writes cache archive with cache id <cache_id_a>(for example)

Then, running CDN_PREFIX=/c/d rush build --to <app>, it calculates cache id to <cache_id_a> which is same as calculated in the first command, and restores the cache archive, which is wrong.

With specifying "CDN_PREFIX" as one of the environment variables, the cache id of second command will be <cache_id_b>, and the second command can get its own cache archive.

Possible solutions

  1. Specify it in "common/config/rush/build-cache.json"
{
  "cachingEnvVariables": [
    "CDN_PREFIX"   <-- here
  ]
}
  1. Specify it in "/config/rush-project.json"
{
  "operationSettings": [
    {
      "operationName": "build",
      "outputFolderNames": [
        "dist"
      ],
      "cachingEnvVariables": [
        "CDN_PREFIX"   <-- here
      ]
    }
  ]
}
  1. Specify it in "common/config/rush/command-line.json"
{
  "commands": [
    {
       "name": "build",
       // ...
       "cachingEnvVariables": [
          "CDN_PREFIX"  <-- here
       ]
    }
  ]
}

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? latest
rushVersion from rush.json? latest
useWorkspaces from rush.json? true
Operating system? Mac
Would you consider contributing a PR? Yes
Node.js version (node -v)? 14

@elliot-nelson @dmichon-msft

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThe issue is asking for a new feature or design changeneeds designThe next step is for someone to propose the details of an approach for solving the problem

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions