Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.119, 1.120, 1.121...

That is my build.gradle file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.2'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

build.sh

#!/bin/bash
gradle clean 
gradle build
#. run_android_ui_tests.sh

My gradle.properities contains only comments.

like image 497
amazingbasil Avatar asked Sep 11 '14 10:09

amazingbasil


2 Answers

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"
like image 57
amazingbasil Avatar answered Sep 22 '22 06:09

amazingbasil


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.

like image 28
dilix Avatar answered Sep 22 '22 06:09

dilix