parameter-passingserverlessgoogle-cloud-rungoogle-cloud-run-jobs

Passing --args to cloud run jobs


I'm trying to pass argument to cloud run jobs in this way:

gcloud run jobs execute aa-hello-world --args="--test1","hello","--test2","world"

(In local works as expected)

but in logs I see this:

cloud run logs

it seems to omit arguments beginning with --

I also tried from console and from nodejs script but in both cases occurs the same.

what am I doing wrong??

thanx


Solution

  • Based on the document, –args value is comma-separated, which you are already applying. But with a value that starts with “--” it could be that Cloud Run's gcloud command doesn’t directly interpret arguments that start with “--” the same way as a typical local shell environment.

    When you pass --args="--test1" "hello" "--test2" "world", Cloud Run might treat the double-dash (--) arguments (like --test1, --test2) as flags or options for the gcloud command itself, rather than arguments for the container being executed.

    I tried to replicate this with the sample app, but was unable to produce the same log (maybe it’s a different setup from your environment).

    Likewise, here are some workarounds you can try:

    gcloud run jobs execute aa-hello-world --args=" --test1","hello"," --test2","world"
    
    gcloud run jobs execute job-quickstart --args=" --test1" --args="hello" --args=" --test2" --args="world"