Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #19 from buildkite/add-inherit-env-flag
Browse files Browse the repository at this point in the history
Add --inherit-env for copying all env from parent shell
  • Loading branch information
lox authored Nov 27, 2018
2 parents c31cd6a + e6e49d5 commit a241968
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ GLOBAL OPTIONS:
--security-group value Security groups to launch task in (required for FARGATE). Can be specified multiple times
--subnet value Subnet to launch task in (required for FARGATE). Can be specified multiple times
--env KEY=value, -e KEY=value An environment variable to add in the form KEY=value or `KEY` (shorthand for `KEY=$KEY` to pass through an env var from the current host). Can be specified multiple times
--inherit-env, -E Inherit all of the environment variables from the calling shell
--help, -h show help
--version, -v print the version
```
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func main() {
Name: "env, e",
Usage: "An environment variable to add in the form `KEY=value` or `KEY` (shorthand for `KEY=$KEY` to pass through an env var from the current host). Can be specified multiple times",
},
cli.BoolFlag{
Name: "inherit-env, E",
Usage: "Inherit all of the environment variables from the calling shell",
},
}

app.Action = func(ctx *cli.Context) error {
Expand All @@ -89,6 +93,12 @@ func main() {
r.Subnets = ctx.StringSlice("subnet")
r.Environment = ctx.StringSlice("env")

if ctx.Bool("inherit-env") {
for _, env := range os.Environ() {
r.Environment = append(r.Environment, env)
}
}

if args := ctx.Args(); len(args) > 0 {
r.Overrides = append(r.Overrides, runner.Override{
Service: ctx.String("service"),
Expand Down

0 comments on commit a241968

Please sign in to comment.