Set bitrise build number during build

I’m trying to set the BITRISE_BUILD_NUMBER during the build process.

My .yml have two scripts:

1 - that sets the BITRISE_BUILD_NUMBER via envman add --key BITRISE_BUILD_NUMBER --value 31

I was expecting that after the build end, the number of the build is 31, but it uses the incremental number from the previous build.

Any feedback on this?

Hy there, the build number will not change like this, if you want to use the build number for somthing then use it as a base that you modify, like
envman add --key my-build-num --value ($BITRISE_BUILD_NUMBER-43)
I would say

Hello, I know that, but what I need is to set the build number in bitrise with the version I want.

could you check this guide out? ->

I already did that. I want to specify the number of the build from my build script.

You could try this script then,
make sure to add $BITRISE_SOURCE_DIR/magicnum.txt to the cache push step

#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x

if [ ! -f $BITRISE_SOURCE_DIR/magicnum.txt ]
  touch $BITRISE_SOURCE_DIR/magicnum.txt

if [ -z "$inc" ]
  echo 1000 > $BITRISE_SOURCE_DIR/magicnum.txt

  envman add --key MY_BUILD_NUMBER --value $((build_number_offset + inc))
  echo $(( inc + 1 )) > ./magicnum.txt

obviously, don’t use 1000 but the number you want

Not sure if this does what I need.

I need to change the #2 to a custom value (ex: 1.1.1) from the build script. Is this possible?


no, that you can not do, but you could create a feature request on it here:

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