0

我在build.gradle中创建了一个额外的任务来为公共github回购提供密钥。Travis CI编译在gradle任务中失败

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

我想与特拉维斯CI服务器端建立这个和在环境变量设置中添加这两个变量FABRIC_API_SECRET和FABRIC_API_KEY。

但构建失败,此例外。

配置项目':app'时发生问题。

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

任何想法我该如何解决这个...?

回答

2

如果你已经设置你的特拉维斯CI设置面板,这些环境变量的值,你应该能够使用带有gradle这个访问环境的值:

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

的原因错误是gradle这个会认为你只是调用属性值并且不访问字符串。

+0

非常感谢!!!!这解决了我的问题:) – eddykordo

+0

很高兴能够帮助建立gradle文件 – griffio