Hope below example help you:
$ foo=testvar
$ bar=testvalue
$ declare "someprefix_${foo}=${bar}"
# your variable
$ echo $someprefix_testvar
testvalue
# one way
$ eval echo '$'"someprefix_${foo}"
testvalue
# other way - prints the contents of the real variable
$ out="someprefix_${foo}"
$ echo ${!out}
testvalue
eval
: Execute arguments as a shell command.
declare
: declare is a bash built-in command that allows you to update attributes applied to variables within the scope of your shell.
Refer : http://mywiki.wooledge.org/BashFAQ/006#Indirection
You need:
$ declare "COMMIT_${CI_COMMIT_SHORT_SHA}_VERSION=${VERSION}"
$ out="COMMIT_${CI_COMMIT_SHORT_SHA}_VERSION"
$ echo ${!out}
Test Results:
[akshay@db1 tmp]$ CI_COMMIT_SHORT_SHA=abcdef
[akshay@db1 tmp]$ VERSION=1.2.0
[akshay@db1 tmp]$ declare "COMMIT_${CI_COMMIT_SHORT_SHA}_VERSION=${VERSION}"
[akshay@db1 tmp]$ out="COMMIT_${CI_COMMIT_SHORT_SHA}_VERSION"
[akshay@db1 tmp]$ echo ${!out}
1.2.0