steps:
- script: |
    # don't set 'set -x' here because this breaks variables
    # https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/readonly-variables.md
    set -eu
    total_envs=0
    for project in $(seq $(MAX_CONTAINER_ENVS)); do
        # no more configured environments
        tests_varname="IPA_TESTS_TO_RUN_${project}"
        [ -z "${!tests_varname:-}" ] && break;
        let "total_envs=total_envs+1"

        name_varname="IPA_TESTS_ENV_NAME_${project}"
        [ -z "${!name_varname:-}" ] && \
            { echo "ipa_tests_env_name_${project} is mandatory."; exit 1; }
    done
    [ "$total_envs" -eq 0 ] && { echo 'Nothing to test'; env | sort ; exit 1; }
    echo "##vso[task.setvariable variable=ipa_tests_total_envs]$total_envs"
  displayName: Generate environment variables
