Change build number from build script

User wants to be able to set the build version from a build script.

Typically my build scripts determine the next version from the status of the repository (latest version tag).
When the build script determines the version to be set I would like to set that version in the bitrise build so I can identify witch build generate each version.

Example:

Change the #2 to a custom value (ex: 1.1.1) from the build script.

35

Thank you for the feature request! :upside_down_face:

Hello!
Is there any way to set Bitrise build number with Android versionCode value?
I need this because I have 2 app build types that share the same build number (but different workflows).
And I want this Bitrise build number to match the app build number (versionCode) so it would be easier to find the needed one.
There is no need to make it like “1.1.1” as in feature request but like simple number (ex: 42).

@PicOrgApp if you can change version numbering in your apps then you can achieve the same result by doing the opposite thing. Build number is exposed as environment variable so you can set versionCodes to be Bitrise build number.
Another option is to include Bitrise build number as a version name suffix.

@koral, @fehersanyi-bitrise

Here is the case:
I have two build variants of the same app (ex: one with main white color and one with main black color). After the push to the branch, Bitrise trigger first build with Bitrise build number №1 (main white color). At the end of this build, I have a step to trigger another build (main black color). Two builds share the same versionCode and branch state (same code but different colors). But Bitrise already incremented build number for second build so now it is Bitrise build number №2 (main black color).

My question is:
Can I make Bitrise build number the same for two different workflow builds that go one by another?

I see here such possible solutions:

  • In one of the steps of second build workflow (black color) manually set environment variable of Bitrise build number to one I need. (As my question above - take value from versionCode and put it in build number)
  • Manually cancel Bitrise build number increment so both builds have the same one. And then enable it for next builds.
  • Cache build number from the first build and use it in second (anyway need to manually set Bitrise build number environment variable from one of the steps).

Can you help me with it?
Thanks in advance.

@PicOrgApp
If you just want to solve this problem (and there are no other conflicting requirements):

Then my solution from previous post is still valid.
In your buildscript add something like this:
versionCode = System.getenv("BITRISE_BUILD_NUMBER").toInteger()
And you will achieve versionCode equal to BITRISE_BUILD_NUMBER.

@koral actually there is one conflicting requirement.
This solution provide me two builds with versionCode equal to BITRISE_BUILD_NUMBER.
But the catch is that versionCode in this two builds are the same. It is the same app but with two build variants (as it should be). But BITRISE_BUILD_NUMBER is different because of the autoincrement feature.

screen

OK, now it is clear.
I’ve commented on that in another thread: Can I change Bitrise build number from workflow?