Can a env variable contain another env variable? like $NUMBER = $BUILD_NUMBER?

Can a env variable contain another env variable? like $NUMBER = $BUILD_NUMBER ? Or it supports operations like $NUMBER = $BUILD_NUMBER + 100 ?

The best way to do this is to add a Script step and do any calculate you want there, then expose the result as an env var using envman . That way all subsequent steps can use the new, exposed env var.

Related docs: http://devcenter.bitrise.io/tips-and-tricks/expose-environment-variable/

A super minimal example workflow:

format_version: "4"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
trigger_map:
- push_branch: '*'
  workflow: primary
- pull_request_source_branch: '*'
  workflow: primary
workflows:
  primary:
    steps:
    - script@1.1.5:
        title: Do calculation
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # do calculation
            NUMBER=$(($BUILD_NUMBER + 100))

            # expose the NUMBER variable as env var to other steps
            envman add --key=NUMBER --value="$NUMBER"
    - script@1.1.5:
        title: Print calculated value
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            echo "NUMBER: $NUMBER"

As these are just regular Bash scripts, you can check any Bash tutorial for supported calculations.

The only special thing is that if you want to expose an environment variable from a script so that subsequent steps can use that variable (anywhere, even in their inputs), you have to use our envman tool (built into the CLI).

The second step is just for printing the number, to demonstrated that itโ€™s indeed shared with subsequent steps.

โ€‹I hope this helps but if you have any questions just let us know! :slight_smile:

P.S.: you can test this bitrise.yml by saving it on your Mac/PC and using our CLI to run it. You can do this with any of your bitrise.io configs too, you can download those in bitrise.yml format and run them locally. Related guide: How to experiment with Bitrise configs locally, on your Mac/Linux