0

I need to update statefulset using Jenkins. To be more precise, to update theme in init container. This is the code that I use in Jenkins (it works fine in terminal):

kubectl patch statefulset test-deploy -n test -p '{"spec": {"template": {"spec":{"initContainers":[{"name": "theme", "image": "xxxx.dkr.ecr.us-east-1.amazonaws.com/testrepo:latest"}]}}}}'

Error that I got: expecting '}', found '-' @ line 293, column 192. age": "xxx.dkr.ecr.us-east-1.am

When I changed double quotes to single quotes: kubectl patch statefulset keycloak-job-deploy -n ci-environment-dev -p '{'spec': {'template': {'spec':{'initContainers':[{'name': 'theme', 'image': '837236160124.dkr.ecr.us-east-1.amazonaws.com/ci/keycloak-theme-thermo-fisher-develop:develop-0.0.1-3'}]}}}}'

I got this:

Error from server (BadRequest): invalid character 's' looking for beginning of object key string

Can you please help me to realize what's wrong with quotes and what command I should use?

user15824359
  • 91
  • 1
  • 11

1 Answers1

0

I figured it out. It was related to screening in Groovy. This is the correct version:

kubectl patch statefulset test-deploy --namespace=${namespace} -p '{\"spec\": {\"template\": {\"spec\":{\"initContainers\":[{\"name\": \"theme\", \"image\": \"${theme}\"}]}}}}'
user15824359
  • 91
  • 1
  • 11