How to set buildConfigField parameters dynamically while building an apk through Jenkins

孤者浪人 提交于 2019-12-03 22:06:32

问题


I have following fields in ProductFlavors of build.gradle,

productFlavors {

    Flavor1 {
        applicationId "com.example.A"
        buildConfigField 'int', 'ID', '123'
    }
}

How can i update these 2 fields according to inputs given from Jenkins.?

Thanks in advance!!


回答1:


You can use following steps:

In your app level build.gradle:

buildscript {
    ext{
        appId="com.example.A"
        Id=123 
    }
    ...
}

change your fields as follows:

productFlavors {

    Flavor1 {
        applicationId appId
        buildConfigField 'int', 'ID', "$Id"
    }
}

From jenkins pass the parameters:

gradlew assesmbleFlavor1 -PappId="${APPLICATION_ID}" -PId="${ID}"

Where ${APPLICATION_ID} and ${ID} are parameters defined in jenkins



来源:https://stackoverflow.com/questions/50176769/how-to-set-buildconfigfield-parameters-dynamically-while-building-an-apk-through

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