BITRISE_BUILD_NUMBER not in env

I’m trying to use $BITRISE_BUILD_NUMBER in a bash script, but it seems not be set in the environment.

I create a very simple workflow, with just one script step.

Contents:

echo $BITRISE_BUILD_NUMBER

It’s echo’s nothing.

When I connect to the VM using Rebuild With Remote Access feature, and run env, I don’t see BITRISE_BUILD_NUMBER:

prd-std-x-e-xcode-10-2-190920085217-zNmZyTryWzvkRckdNb6n8g:~ vagrant$ env
ANDROID_NDK_VERSION=r16b
ANDROID_HOME=/usr/local/share/android-sdk
BITRISE_OSX_STACK_REV_ID=v2019_09_11_2
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/
SSH_CLIENT=::1 49192 22
ANDROID_SDK_ROOT=/usr/local/share/android-sdk
BITRISE_DEPLOY_DIR=/Users/vagrant/deploy
BITRISE_KEYCHAIN=bitrise.keychain
BITRISE_LIBRARY_DIR=/Users/vagrant/Library/MobileDevice/Provisioning Profiles
BITRISE_SOURCE_DIR=/Users/vagrant/git
SSH_TTY=/dev/ttys000
LC_ALL=en_US.UTF-8
DOTPROFILE_LOADED=1
BITRISE_IO=true
USER=vagrant
HOMEBREW_NO_ANALYTICS=1
HOMEBREW_NO_AUTO_UPDATE=1
BITRISE_TOOLS_FOLDER_PATH=/Users/vagrant/bitrise/tools
BITRISE_SYM_ROOT=/Users/vagrant/build
MATCH_KEYCHAIN_PASSWORD=vagrant
BITRISE_STEP_DIR=/Users/vagrant/stepdir
MAIL=/var/mail/vagrant
PATH=/Users/vagrant/.jenv/shims:/Users/vagrant/.rbenv/shims:/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/go/libexec/bin:/Users/vagrant/go/bin:/Users/vagrant/bitrise/tools/cmd-bridge/bin/osx:/opt/android-ndk:/usr/local/share/android-sdk/tools:/usr/local/share/android-sdk/tools/bin:/usr/local/share/android-sdk/platform-tools:/usr/local/flutter/bin:/Users/vagrant/.jenv/bin
JENV_LOADED=1
PWD=/Users/vagrant
LANG=en_US.UTF-8
BITRISE_FOLDER_PATH=/Users/vagrant/bitrise
BITRISE_STEP_FORMATTED_OUTPUT_FILE_PATH=/Users/vagrant/bitrise/stepdata/stepoutput
BITRISE_PROFILE_DIR=/Users/vagrant/profiles
BITRISE_STEP_DATA_FOLDER_PATH=/Users/vagrant/bitrise/stepdata
RBENV_SHELL=bash
BITRISE_KEYCHAIN_PASSWORD=vagrant
SHLVL=1
HOME=/Users/vagrant
LANGUAGE=en_US.UTF-8
LC_TERMINAL_VERSION=3.3.4
CI=true
DOTBASHPROFILE_LOADED=1
LOGNAME=vagrant
JENV_SHELL=bash
SSH_CONNECTION=::1 49192 ::1 22
LC_CTYPE=UTF-8
BITRISE_OBJ_ROOT=/Users/vagrant/bin
GOPATH=/Users/vagrant/go
ANDROID_NDK_HOME=/opt/android-ndk/android-ndk-r16b
LC_TERMINAL=iTerm2
DOT_BITRISE_PROFILE_LOADED=1
BITRISE_TOOLS_CMD_BRIDGE_PATH=/usr/local/bin/cmd-bridge
DOTBASHRC_LOADED=1
_=/usr/bin/env
OLDPWD=/Users/vagrant/git
prd-std-x-e-xcode-10-2-190920085217-zNmZyTryWzvkRckdNb6n8g:~ vagrant$

If I look here: https://devcenter.bitrise.io/builds/available-environment-variables/

…I would expect to see much more environment variables when I run env.

Am I doing something wrong?

Hi @dirkpostma!

Can you send us the related builds URL? The problem here I believe is that when you remote access to the machine, you are no longer dealing with the build through the CLI - which exposes these variables.

On linked devcenter page BITRISE_BUILD_NUMBER is listed in Exposed by Bitrise.io section not Exposed by the Bitrise CLI

That’s absolutely true, although the principle is the same - the website is a layer “above” the build machine

OK, so description on devcenter should also contain that info.
Currently there is nothing suggesting that there are some layers.

Completely agreed about the info, not 100% what the behaviour should be, that’s why I’m eagerly waiting the request build :slight_smile:

I’m not sure why, but BITRISE_BUILD_NUMBER works in “website builds” now. Probably be my fault.

As check, I also rebuild and logged in to the vm remotely. Then, BITRISE_BUILD_NUMBER does not show up when I run env. Should env variable BITRISE_BUILD_NUMBER also be exposed when I remotely login to the VM?

https://app.bitrise.io/build/5bc8596a02676380

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