【问题标题】:Travis CI build failed in gradle taskTravis CI 构建在 gradle 任务中失败
【发布时间】:2016-04-30 05:37:18
【问题描述】:

我在 build.gradle 中创建了一个额外任务,为公共 github 存储库提供密钥。

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)
    }
}}

我想用 travis ci 服务器端构建它,并在环境变量设置中添加这两个变量 FABRIC_API_SECRET 和 FABRIC_API_KEY。

但构建失败并出现此异常。

配置项目 ':app' 时出现问题。

在项目 ':app' 上找不到属性 'FABRIC_API_SECRET'。

有什么想法可以解决这个问题...?

【问题讨论】:

    标签: android continuous-integration travis-ci continuous-deployment


    【解决方案1】:

    如果您在 Travis CI 设置面板中设置了这些环境变量值,您应该可以使用 gradle 访问环境值:

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

    错误的原因是gradle认为你是在调用一个属性值,而不是访问一个字符串。

    【讨论】:

    • 很高兴能够为 gradle 构建文件提供帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多