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
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