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? -> https://devcenter.bitrise.io/builds/build-numbering-and-app-versioning/

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 ]
then
  touch $BITRISE_SOURCE_DIR/magicnum.txt
fi

inc=$(<$BITRISE_SOURCE_DIR/magicnum.txt)
if [ -z "$inc" ]
then
  echo 1000 > $BITRISE_SOURCE_DIR/magicnum.txt
  inc=$(<$BITRISE_SOURCE_DIR/magicnum.txt)
fi


if [ $BITRISE_TRIGGERED_WORKFLOW_TITLE == "test" ]
then
  build_number_offset=1
  envman add --key MY_BUILD_NUMBER --value $((build_number_offset + inc))
  echo $(( inc + 1 )) > ./magicnum.txt
fi

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?

35

no, that you can not do, but you could create a feature request on it here: http://discuss.bitrise.io/c/feature-request

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