I am getting an error message
Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
while running AWS CLI on Jenkins pipeline to create task definition for EC2 container service. The interesting thing is this script is able to run in command line without any error.
aws ecs register-task-definition --family ${FAMILY} --container-definitions "[{\"name\":\"wildfly\",\"image\":\"${REPOSITORY}\",\"memory\":3024,\"essential\":true,\"portMappings\":[{\"containerPort\":8080,\"hostPort\":8080,\"protocol\":\"tcp\"}]}]"`
This is the complete error message
aws ecs register-task-definition --family wildfly2-b47 --container-definitions [{name:wildfly, image:****/backend:b47, memory:3024, essential:true, portMappings:[{containerPort:8080, hostPort:8080, protocol:tcp}]}]
Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
This the jenkins stage code
stage('Deploy')
withCredentials([string(credentialsId: 'ecr-repository', variable: 'repo'),
[$class: 'AmazonWebServicesCredentialsBinding',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
credentialsId: 'ecr-credentials',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
sh '''
bash
set -x
export AWS_DEFAULT_REGION=us-west-2
CLUSTER="default"
VERSION=b${BUILD_NUMBER}
FAMILY=nxpmp2-${VERSION}
SERVICE="backend"
REPOSITORY=${repo}/backend:${VERSION}
#Register the task definition in the repository
aws ecs register-task-definition --family ${FAMILY} --container-definitions "[{"name": "wildfly", "image": ${REPOSITORY}, "memory": 3024, "essential": true, "portMappings": [{"containerPort": 8080, "hostPort": 8080, "protocol": "tcp" } ] }]"
#Update the Service
#aws ecs update-service --cluster ${CLUSTER} --region ${AWS_DEFAULT_REGION} --service ${SERVICE} --task-definition ${FAMILY}
--desired-count 1
'''
}
Please help me on this