radar
radar

Reputation: 605

Environment Variables not propagating into Gradle test environment

I'm trying to run a Gradle build, and am restricted to using version 1.8. I have some tests that require environment variables to be set, but they keep failing. I used the following code to debug:

test {
    println System.getenv("PATH")
}

And it prints out the correct value. However, it looks like this isn't persisting through to the test environment, as it continues to fail because the appropriate data cannot be found. Is there anything in particular that must be done in order to have the process' environment variables be passed through to the test VM's environment variables?

I am aware that after Gradle 2.0 you can use

environment [var] [value]

to set test environment variables, but as I said, I am restricted to 1.8.

Any help would be appreciated.

Upvotes: 1

Views: 380

Answers (1)

Mark Vieira
Mark Vieira

Reputation: 13466

This can most definitely be done with Gradle 1.8.

test {
  environment 'NAME', 'VALUE'
}

Upvotes: 1

Related Questions