2016-09-28 50 views
0

我想知道是否有可能使用的versionName变量在我gradle这个文件的DefaultConfig:是否可以在我的gitlab-ci文件中使用Gradle配置变量?

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.2" 

defaultConfig { 
    applicationId "app" 
    minSdkVersion 16 
    targetSdkVersion 24 
    versionCode 1 
    versionName "1.0" 
    multiDexEnabled true 
} 

buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

    lintOptions { 
     abortOnError false 
    } 
} 

在我gitlab-CI文件:

stages: 
    - build 

release: 
    stage: build 
    only: 
    - release 
    script: 
    - ./gradlew assembleRelease 
    # Here I need to use the value of versionName in my gradle file. 

是否有这样做的一个简单的方法这个?

回答

2

我结束了在gitlab-CI文件中的命令行脚本这样做:

export VERSION = $(grep -E "versionName " app/build.gradle | cut -d "\"" -f2) 

这样我可以用$ VERSION访问的的versionName文件中。

相关问题