Get environment variable from Gradle

I did try in many ways and deeply search on net, but didn’t find a way to read environment variables from Gradle.
I store BINTRAY_USER and BINTRAY_APIKEY, and I’m trying to access them from Gradle ( kotlin-dsl ) like following

System.getEnv("BINTRAY_USER")

but with no success.

Is there a solution rather that write a bash script that is not my field either? Also have some info in gradle.properties, so I cannot overwrite them

Thank you

I’m not a gradle expert so apologies if this wildly off but it does look like you can pass envars directly to gradle. You can see an example here. I’m guessing you can reference them directly in your file when passed through the command. Here’s the reference in the docs on settings the project properties, and the reference on usage.

So you would pass the envar through the shell to gradlew and then you can access it within gradle. Would that work?