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

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.


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"