Read versionName of build.gradle from Jenkins

后端 未结 3 1018
一整个雨季
一整个雨季 2021-01-12 04:57

I\'m using Jenkins for my Android app builds. On every build, I get some info, like build number, etc...

I\'m searching a way to read the versionName v

3条回答
  •  醉梦人生
    2021-01-12 05:28

    You could do this by adding an Execute Shell step which determines the versionName, and exporting it as an environment variable using the EnvInject Plugin.

    Assuming your build.gradle contains:

    versionName = myname
    

    You can add this script:

    v=$(cat build.gradle  | grep versionName | awk '{print $3}')
    echo MY_VERSION_NAME=${v} > env.properties
    

提交回复
热议问题