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

前端 未结 1 735
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 02:50

I have following fields in ProductFlavors of build.gradle,

productFlavors {

    Flavor1 {
        applicationId \"com.example.A\"
        buildConfigField \         


        
1条回答
  •  攒了一身酷
    2021-01-07 03:19

    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

    0 讨论(0)
提交回复
热议问题