与摇篮性能特拉维斯CI环境变量 [英] Travis CI environment variables with Gradle properties

查看:217
本文介绍了与摇篮性能特拉维斯CI环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用特拉维斯慈ENV变量作为摇篮的属性?

How can I use travis-ci env variables as Gradle's properties?

我在本地有我的gradle这个路径下gradle.properties有:

I locally have my gradle.properties under the gradle path having:

sonatypeRepo = abcd

这是我的build.gradle使用:

Which is used in my build.gradle:

uploadArchives {   
    //more     
    repository(url: sonatypeRepo) {
        // more
    }
    //more
}

当然本地它的作品。特拉维斯我已经加入下设置变量,所以我看到生成日志:

Of course locally it works. In travis I have added the variable under settings so I see the build log:

Setting environment variables from repository settings
$ export sonatypeRepo=[secure]

和失败,如:

FAILURE: Build failed with an exception.
* Where:
Build file '/home/travis/build/Diolor/Swipecards/library/build.gradle' line: 49
* What went wrong:
A problem occurred evaluating project ':library'.
> No such property: sonatypeRepo for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer


我如何使用特拉维斯环境变量作为格拉布尔属性的也有当地的构建,因为它?


How can I use the Travis' env variable as a Grable property but also have the local build as it?

推荐答案

我只是偶然发现这一点。

I just stumbled on this too.

这是我如何得到它的工作:

This is how I got it to work:

在我的build.gradle

In my build.gradle

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

在我的$ HOME / .gradle / gradle.properties

In my $HOME/.gradle/gradle.properties

blahUser=batman
blahPwd=eatsworms

所以,我需要这个特拉维斯 - 词 - 我不认为有一个$ HOME / .gradle / gradle.properties的概念但是可以添加环境变量.travis.yml。

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.

基本上,previously提到的,如果属性是'有'; gradle这个使用它,否则要求环境吧。在我的情况,需要在hasProperty()检查,以便特拉维斯不会产生财产未发现异常.....

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.....

心连心......

这篇关于与摇篮性能特拉维斯CI环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆