bazelbuild / bazelbuild/bazel

Use environment variables in .bazelrc via string interpolation

Open
#10,904 38 comments 40 reactions 0 assignees View on GitHub
P2 team-OSS type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the problem / feature request:

I want to use environment variables in my .bazelrc via string interpolation

### Feature requests: what underlying problem are you trying to solve with this feature?

I'm running a remote Bazel cache secured with Basic Auth. I don't want to hardcode basic auth credentials into the `.bazelrc` checked into the repository.

Example `.bazelrc`:

```
build --remote_cache=https://username:password@mybazelcache.example.com
```

I would rather do something like this:

```
build --remote_cache=https://${CACHE_USERNAME}:${CACHE_PASSWORD}@mybazelcache.example.com
```

### What operating system are you running Bazel on?

macOS Catalina 10.15.3

### What's the output of `bazel info release`?

INFO: Invocation ID: 067b442a-efd2-431e-b39d-9ea6e2467bf3
release 2.0.0

### Have you found anything relevant by searching the web?

Related issue comment: https://github.com/bazelbuild/bazel/issues/4635#issuecomment-365998683

Contributor guide

Open the contributing guide

Research direction

Start with Bazel's .bazelrc option parsing and review the related discussion in issue #4635. Define the interpolation and escaping behavior, including how missing environment variables and credentials are handled. Done means a checked-in .bazelrc can obtain CACHE_USERNAME and CACHE_PASSWORD from the environment without hardcoding them.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.