Travis CI 构建在 gradle 任务中失败
Travis CI build failed in gradle task
我在 build.gradle 中创建了一个额外的任务来为 public 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”时出现问题。
Could not find property 'FABRIC_API_SECRET' on project ':app'.
有什么办法可以解决这个...?
如果您在 Travis CI 设置面板中设置了这些环境变量值,您应该能够使用 gradle 使用以下方法访问环境值:
entry(key: "apiSecret", value: "$System.env.FABRIC_API_SECRET")
entry(key: "apiKey", value: "$System.env.FABRIC_API_KEY")
错误的原因是 gradle 认为您正在调用 属性 值而不是访问字符串。
我在 build.gradle 中创建了一个额外的任务来为 public 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”时出现问题。
Could not find property 'FABRIC_API_SECRET' on project ':app'.
有什么办法可以解决这个...?
如果您在 Travis CI 设置面板中设置了这些环境变量值,您应该能够使用 gradle 使用以下方法访问环境值:
entry(key: "apiSecret", value: "$System.env.FABRIC_API_SECRET")
entry(key: "apiKey", value: "$System.env.FABRIC_API_KEY")
错误的原因是 gradle 认为您正在调用 属性 值而不是访问字符串。