For AI agents: the documentation index is at https://docs.gradle.org/llms.txt. Request any page with the header Accept: text/markdown to get Markdown. User manual pages are also available as Markdown by replacing .html with .md in the URL.

withEnvironment

abstract fun withEnvironment(@Nullable environmentVariables: @Nullable Map<String, String>): GradleRunner(source)

Sets the environment variables for the build. null is permitted and will make the build use the system environment.

When environment is specified, running with isDebug is not allowed. Debug mode runs in-process and TestKit must fork a separate process to pass environment variables.

Return

this

Since

5.2

Parameters

environmentVariables

the variables to use, null is allowed.