Can I change Bitrise build number from workflow?

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.

Hi @PicOrgApp!

The $BITRISE_BUILD_NUMBER variable can not be modified from within your builds, only in your app’s settings on the website.

That said, what is your solution for incrementing versionCode currently? What we do recommend here: Build numbering and app versioning | Bitrise DevCenter is that you use the Change Android versionCode and versionName step to link your versionCode and the $BITRISE_BUILD_NUMBER.

Now I’m not 100% sure, but as I understand what you want is for both builds to have the same number. You can achieve this by offsetting this step accordingly.

So for example, let’s say, you want your versionCode to be 2.0 and your next Bitrise Builds number is 100.

In this case, n workflow №1, you will want to have offset to have the value of -98

And for workflow №2 you want the same step to have an offset -99

So essentially, you can just offset the second workflows number by one backwards compared to the first workflow, to achieve the same value :slight_smile:

@bitce Thanks for information!
So I assume your solution will make my two builds have the same versionCode value but different Bitrise build number (the ones I want to be the same). And I think there is no possible solution for this… :frowning:

By different Bitrise build numbers I mean this ones:

screen

The main thing I need is to identify by Bitrise UI that two builds are the same ones but with different build variants.

I see, no, that wouldn’t be possible, two separate builds can’t have the same number.

I would say that’s not true :slight_smile:
You can overwrite next build number value in settings tab:
image
You can set lower value and achieve duplicate build numbers.

However, build number is by definition user friendly autoincrementing integer.

Changing build number is rather something hardly ever done and if it happen it is rather one-time action for given app and it is changed to higher values. I can imagine cases like migrating from another CI or splitting/merging Bitrise apps when it can be useful. I don’t expect that feature like that: Change build number from build script will be implemented soon.

@PicOrgApp if your bigger problem is to make Bitrise builds more easily discoverable you can try to solve it in another ways. Build number is not designed for such use case.

@koral is absolutely right here!

The website doesn’t actually enforce build number uniqueness, so what is described above is possible, but admittedly does not sound like a solution as it’s only achievable through manually doing this on the website for each of those builds.

@koral @bitce
Thanks for help :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.