I have ran this example using this job
Everything worked well.
Now I am trying to see if there is a way to pass parameters to jobs running on Cloud Run.
I understand I can use the command to create jobs with a --message-body argument like this:
gcloud scheduler jobs create http JOB_NAME \
--location REGION \
--schedule="*/3 * * * *" \
--uri="https://REGION-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/PROJECT_ID/jobs/CLOUD_RUN_JOB_NAME:run" \
--http-method POST \
--oauth-service-account-email [email protected]
--message-body="This is the body"
However while checking the documentation for Cloud Run jobs here.
I don't see parameters being mentioned anywhere. The idea is that depending on a JSON that contains the parameters we can run different kind of jobs (it's a same job that changes its operation based on the parameters)
This is now possible using the REST API for Cloud Run Jobs.
A full working repo of how to do this is here: https://github.com/CharlieDigital/gcr-invoke-job-overrides
A more in depth writeup here: https://medium.com/@chrlschn/programmatically-invoke-cloud-run-jobs-with-runtime-overrides-4de96cbd158c
The sample is in C#/.NET, but it's easy enough to translate to any other language.
Here's the log output of the environment variables and entry point args:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With