Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can't use kubectl patch using atlassian/azure-aks-deploy

Hello everyone,


I'm trying to use a kubectl patch command to update a deployment by changing a metadata label on my deployment, the command i'm using is this one:

kubectl patch deployment my-deployment -n my-namespace -p '{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"redeploy\":\"55\"}}}}}'

When running it on power shell it works perfectly but when i add it to my pipeline i get all sorts of errors, currently my step is as follows:


- pipe: atlassian/azure-aks-deploy:1.0.2
                AZURE_APP_ID: $AZURE_APP_ID
                KUBECTL_COMMAND: 'patch deployment my-deployment'
                KUBECTL_ARGUMENTS: '-n my-namespace -p ''{\\"spec\\":{\\"template\\":{\\"metadata\\":{\\"labels\\":{\\"redeploy\\":\\"$BITBUCKET_BUILD_NUMBER\\"}}}}}'''

But the output of the pipeline is
INFO: running kubectl command patch deployment my-deployment using generic handler
kubectl patch deployment my-deployment -n my-namespace -p '{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"redeploy\":\"55\"}}}}}'
Error from server (BadRequest): json: cannot unmarshal string into Go value of type map[string]interface {}
I've tried scaping that string in all sorts of ways but nothing works, even tried using the yaml style for the patch command with the same outcome. Is there something obvious i'm missing here?

1 answer

1 accepted

0 votes
Answer accepted

Answering my own question, it seems that the kubectl version being using a little far behind the current version, so the correct syntax was:


                KUBECTL_COMMAND'patch deployment my-deployment'
                KUBECTL_ARGUMENTS'-n my-namespace -p {"spec":{"template":{"metadata":{"labels":{"redeploy":"$BITBUCKET_BUILD_NUMBER"}}}}}'

Just had to remove the backslashes and the extra single quotes that marked the patch string

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

79 views 2 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you