Instead of using individual variables with names beginning with B2_, you could use an associative array (B2). e.g.
Note: the following is specific to zsh. ksh and bash also have associative arrays, but the syntax for initialising and using them is different (see below).
typeset -A B2
# initialise array
B2=(ACCOUNT_ID 12345 ACCOUNT_KEY 54321 REPOSITORY somewhere)
# two different ways of adding elements to the array
B2[FOO]=bar
B2+=(NAME fred)
for key val in ${(kv)B2}; do
echo "$key: $val"
done
Output for that example would be:
ACCOUNT_KEY: 54321
FOO: bar
REPOSITORY: somewhere
ACCOUNT_ID: 12345
NAME: fred
You can also print the entire array (in a form suitable for re-use in a script or on the command line) with typeset -p:
% typeset -p B2
typeset -A B2=( ACCOUNT_ID 12345 ACCOUNT_KEY 54321 FOO bar NAME fred REPOSITORY somewhere )
The same operations in ksh or Bash would be as follows:
# initialise it
typeset -A B2
B2=([ACCOUNT_ID]=12345 [ACCOUNT_KEY]=54321 [REPOSITORY]=somewhere)
# add elements
B2[FOO]=bar
B2+=([NAME]=fred)
# get a list of the keys and use them as indexes to get the values
for key in "${!B2[@]}"; do
echo "$key: ${B2[$key]}"
done
# print the entire array
typeset -p B2
B2_?