Setting environment variables in gradle

Is there a way to set environment variables in gradle?

I use the tomcat plugin to start Tomcat from a war i built. I need to set some environment variables before the server is starting. How i can i do that?

From what I can see in the Gradle Tomcat plugin docs, the plugin runs Tomcat in the Gradle process, in which case you can set environment variables via ‘GRADLE_OPTS’. Alternatively, you might want to look into the Gradle Cargo or Gradle Arquillian plugin, which can also run containers in an external process.

What is exactly GRADLE_OPTS? How i use it to set my own environment variable?

Sorry, I mixed this up. Environment variables for the Gradle process can only be set from outside Gradle, in a manner that’s appropriate for your environment/OS.