Set bitrise build number during build

#1

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?

0 Likes

#2

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

0 Likes

#3

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

0 Likes

#4

could you check this guide out? -> https://devcenter.bitrise.io/builds/build-numbering-and-app-versioning/

0 Likes

#5

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

0 Likes

#6

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

0 Likes

#7

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

0 Likes

#8

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

0 Likes

closed #9

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

0 Likes