Hey, I'm currently using gradle 7.1.1 to set env v...
# gradle
s
Hey, I'm currently using gradle 7.1.1 to set env variables as below (along w/ kotest):
Copy code
# build.gradle.kts

tasks.withType<Test> {
    ...
    environment = mapOf(
        "VERSION" to "1.0",
        "TYPE" to "some-type",
        "NAME" to "some-name",
        "PATH" to "some-path",
    )
}
Whilst this works, I'm trying to remove this block and instead set these env variables in the bash script show below. The current approach of simply exporting the values doesn't seem to be making them available to the JVM.
Copy code
# run-tests.sh

export VERSION=1.0
export TYPE=some-type
export NAME=some-name
export PATH=some-path

./gradlew test --tests HealthCheck
Any suggestions on how to resolve this would be much appreciated.
v
If you want to have them in the test process, you have to configure it in your build script. If you want to set the actual values in the shell script, then use something like
Copy code
tasks.withType<Test> {
    ...
    environment = mapOf(
        "VERSION" to System.env["VERSION"],
        "TYPE" to System.env["TYPE"],
        "NAME" to System.env["NAME"],
        "PATH" to System.env["PATH"]
    )
}
No environment from outside is automatically forwarded to the tests or the tests would be flaky just by having a different environment which is bad and unwanted in 90% of the cases.
s
ahh that makes sense, thank you!