Yes, the syntax is bad. Basically the problem that I see is related to your quoting shell command. This is not true:
sh 'AMI_ID=$(grep artifact_id /opt/repository/jenkins/workspace/crspng-CCPDev-ccp-ft-AMI/manifest.json | awk -F "\"" '{print $4}'| awk -F ":" '{print $2}')'
You exit the single quote for {print $4} , which is probably interpreted as closing groovy.
I'm not sure I understand why it gives an error, but I think that if you could most easily solve it by triple single quoting your shell command:
sh '''AMI_ID=$(grep artifact_id /opt/repository/jenkins/workspace/crspng-CCPDev-ccp-ft-AMI/manifest.json | awk -F "\"" '{print $4}'| awk -F ":" '{print $2}')'''
I'm not sure what the next echo line will work. Firstly, AMD_ID does not exist where you use echo . it existed only in a shell. In addition, $ AMD_ID does not exist as a valid groovy variable. I'm not quite sure what you are trying to do with this echo expression, but if it really works, it will not do what you expect from it.
source share