Hello
I'm trying to pass --arg to cloud run jobs in this way:
gcloud run jobs execute aa-hello-world --args="--cmd=hello"
but in logs I see this:
and when I try
gcloud run jobs execute aa-hello-world --args="--startDate=hello"
in logs I see:
Also I tried with nodejs cloud run library and executing it from de cloud console overriding arguments
what am I doing wrong??
Hi @JorgeCbx,
Welcome to Google Cloud Community!
The problem you’re encountering might be related to the way Cloud Run Jobs deals with argument positions. From the logs, it appears that the arguments are not being correctly split. Try passing the arguments as distinct strings and see if that resolves the issue:
gcloud run jobs execute aa-hello-world --args="--cmd","hello"
or
gcloud run jobs execute aa-hello-world --args="--startDate","hello"
Also, make sure that your container entrypoint is configured properly for argument passing. If you are using package.json, update the start script to use '$@' so that it can pass in arguments.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.
Hello
I have modified the package.json adding what you have told me like this:
"main": "src/index.js $@",
"scripts": {
"start": "node src/index.js $@",
}
And I tried with this command:
gcloud run jobs execute aa-hello-world --args="--test1","hello","--test2","world"
In logs I see:
it seems to omit arguments beginning with --
:S
also I ask in stack overflow here, maybe arguments started with "--" not parsed by cloud run correctly. It a bug in the service?
Any solution?
I saw your Stack Overflow question. One of the users recommended using spaces.
Maybe you can change your code to handle the args in your application like this:
const args = process.argv.map(arg => arg.trim()); // Remove extra spaces
console.log("Parsed arguments:", args);