Florian
Florian

Reputation: 143

Add multiple commands in cronjob.yaml

I want to run two commands in my cronjob.yaml one after each other. The first command runs a python-scipt and the second changes an environment variable in another pod. The commands added separately work.

This is what I'm trying right now (found the syntax in How to set multiple commands in one yaml file with Kubernetes? ) but it gives me an error.

command:
- "/bin/bash"
- "-c"
args: ["python3 recalc.py && kubectl set env deployment recommender --env="LAST_MANUAL_RESTART=$(date)" --namespace=default"]

The error I get in cloudbuild:

error converting YAML to JSON: yaml: line 30: did not find expected ',' or ']'

(for the long line)

Upvotes: 1

Views: 2433

Answers (1)

coderanger
coderanger

Reputation: 54211

You have nested double quotes, try something more like this:

command:
- /bin/bash
- -c
- python3 recalc.py && kubectl set env deployment recommender --env="LAST_MANUAL_RESTART=$(date)" --namespace=default

i.e. without the outer double quotes.

Upvotes: 4

Related Questions