Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set envVars in command alias #90

Open
evbo opened this issue Jan 3, 2019 · 1 comment
Open

how to set envVars in command alias #90

evbo opened this issue Jan 3, 2019 · 1 comment

Comments

@evbo
Copy link

evbo commented Jan 3, 2019

Is there a way to set envVars for revolver? Here's my interpretation of the readme applied to a scenario where I want my dev server to run locally with dev only env vars:

addCommandAlias(
  "server-dev",
  "; project server" +
  "; set envVars in reStart := Map(\"aws_region\" -> \"us-east-1\")" +
  "; reStart"
)

but I cannot access those variables in any task that restart triggers, e.g. this fails:println(sys.env("aws_region"))

of course I can get this working simply by exporting manually, like:

export aws_region=us-east-1 && sbt server-dev
@evbo
Copy link
Author

evbo commented Jan 17, 2019

simplest way I've managed to do this is calling a bash script from an sbt task that in turn sets environment and then runs sbt. This way, the environment variables exported from the bash script are injected into the process sbt is running on.

leaving open in case there's a simpler approach, otherwise feel free to close if this is it:

lazy val bashTask = taskKey[Unit]("exports env vars and calls the sbt build with those vars injected")
lazy val bashTaskSetting = bashTask := {
  import scala.sys.process._
  Seq("scripts/setEnv.sh", "args") !
}

addCommandAlias(
  "set-env-then-build",
  "; bashTask"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant