I have the following code snippet in my Declarative Jenkins pipeline wherein I am trying to assign a groovy array variable 'test_id' to a shell array variable 't_id'.
script{
def test_id
sh """
t_id=($(bash -c \" source ./get_test_ids.sh ${BITBUCKET_COMMON_CREDS_USR} ${BITBUCKET_COMMON_CREDS_PSW} ${env.StoryId} \"))
test_id=${("${t_id[@]}")}
"""
echo "${test_id[0]}"
echo "${test_id[1]}"
}
The shell commands work in the bash shell but when I add the multi line sh step, I am getting the below syntax error when I run it in Jenkins. Can you please help?
WorkflowScript: 46: illegal string body character after dollar sign;
solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}" @ line 46, column 20.
sh """
^