Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 1 KB

README.md

File metadata and controls

43 lines (35 loc) · 1 KB

Bazel env file rules

Build Status

This rule can be used to import environment vars into a Bazel workflow directly from an environment file.

Basic usage

In .env:

# Vars need to be quoted
SOME_ENV="Hello, world!"

In WORKSPACE:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    # Get copy pase instructions for the http_archive attributes from the
    # release notes at https://github.com/worldpeaceio/rules_envfile/releases
)

load("@io_worldpeace_rules_envfile//:def.bzl", "envfile")
envfile(
    name = "envfile",
    files = [
        "//.env"
    ]
)

Example using an env var in a BUILD.bazel file:

load("@envfile//:environment.bzl", "SOME_ENV")

sh_test(
    name = "test",
    srcs = ["test.sh"],
    env = {
        "SOME_ENV": SOME_ENV,
    },
)