Travis CI environment variables with Gradle properties

允我心安 提交于 2019-12-03 05:32:43

I just stumbled on this too.

This is how I got it to work:

In my build.gradle

def uzer = hasProperty('blahUser') ? blahUser : System.getenv('blahUser')
def creds = hasProperty('blahPwd') ? blahPwd : System.getenv('blahPwd')

In my $HOME/.gradle/gradle.properties

blahUser=batman
blahPwd=eatsworms

So I needed this for travis-ci -- which I don't think has a notion of a $HOME/.gradle/gradle.properties But you can add environment variables to .travis.yml.

Basically, as previously mentioned, if the property is 'there'; gradle uses it, otherwise asks the environment for it. In my case the 'hasProperty()' check was needed so travis wouldn't generate a property not found exception.....

hth...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!