eddykordo
eddykordo

Reputation: 607

Travis CI build failed in gradle task

I've create an extra task in my build.gradle to provide secret keys for public github repo.

afterEvaluate {
initFabricPropertiesIfNeeded()
}
def initFabricPropertiesIfNeeded() {
def propertiesFile = file('fabric.properties')
if (!propertiesFile.exists()) {
    def commentMessage = "This is autogenerated fabric property from system environment to prevent key to be committed to source control."
    ant.propertyfile(file: "fabric.properties", comment: commentMessage) {
        entry(key: "apiSecret", value: FABRIC_API_SECRET)
        entry(key: "apiKey", value: FABRIC_API_KEY)
    }
}}

I want to build this with travis ci server side and add these two variables FABRIC_API_SECRET and FABRIC_API_KEY in environment variables settings.

But the build failed with this exception.

A problem occurred configuring project ':app'.

Could not find property 'FABRIC_API_SECRET' on project ':app'.

Any ideas how can I solve this ...?

Upvotes: 0

Views: 170

Answers (1)

griffio
griffio

Reputation: 244

If you have set these environment variable values in your Travis CI settings panel you should be able to access the environment values with gradle using:

 entry(key: "apiSecret", value: "$System.env.FABRIC_API_SECRET")
 entry(key: "apiKey", value: "$System.env.FABRIC_API_KEY")

The reason for the error is that gradle thinks you are invoking a property value and not accessing a string.

Upvotes: 2

Related Questions