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


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, 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?

Hi :slight_smile:

I’m having the same issue…
Did you manage to solve it ?

Same issue here want to use the CIRCLE_BUILD_NUM to set the versionCode in the gradle build and name the file with it. But gradle reports it as null even though I do System.getEnv(“CIRCLE_BUILD_NUM”)