How to set android app version by number of build in Jenkins?

后端 未结 4 972
名媛妹妹
名媛妹妹 2021-02-13 12:12

Application is automatically building by jenkins after successful push, but version is always 1.0. Instead of \"0\" I want to insert number of corresponding build in jenkins: 1.

相关标签:
4条回答
  • 2021-02-13 12:48

    Problem solved by inserting these two strings into build.gradle's defaultConfig:

    def env = System.getenv()
    versionName "1." + env['BUILD_NUMBER']
    

    instead of

    versionName "1.0"
    
    0 讨论(0)
  • 2021-02-13 12:50

    You have to make some preprocessing of your Manifest or build.gradle.

    Fro example

    1. 1st build step is to run some script to paste version that you need.
    2. 2nd build step is to build you app.

    I recommend you to get a system value that you can determine in each build you have, so you can change version of the app yourself in build configuration.

    0 讨论(0)
  • 2021-02-13 12:59

    the configuration at the build.gradle should be

    defaultConfig {
        ...
    
        versionName System.getenv("APP_VERSION") as String ?: "3.0.0 (Default)"
    
        ...
    }
    

    Jenkins Configuration for parse the build parameter

    0 讨论(0)
  • 2021-02-13 13:03

    Best approach will be to use gradle release plugin for this. Using this you can do automatic version inclement version in your manifest file. You can have a look here

    You can use it for tagging your source tree as well for different versions.

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