override arguments and environments Cloud run job execution via REST API (using curl command)

Hi,

May I know please, how to override arguments and environment variables when execute cloud run job via REST API (using CURL command). below is the command for your reference.

I have below arguments and environment variables specified when creating the cloud run job, i would like to override these arguments and environment variable when execute the cloud run job via REST API using curl command, Please help me.

Arguments: appv1, appv2
Environment variables:
"app_version": "v2"

Command:

curl -H "Content-Type: application/json" -H "Authorization: Bearer ${gcloud auth print-access-token}" -X POST -d '' https://us-central1-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/{PROJECT-ID}/jobs/pytho...

Solved Solved
0 2 1,508
1 ACCEPTED SOLUTION

Hi @robertcarlos,

Thanks for your response on my query,

We can override the arguments and environment variables of cloud run job via REST API by passing the request JSON when execute the job. please find below the JSON value I passed. its working as expected.

JSON Value:

{"overrides": {"containerOverrides": [{"args": ["appV3", "appV4"], "env": [{"name": "app_version", "value": "V3"}], "clearArgs": "FALSE"}]}}

command:
curl -H "Content-Type: application/json" -H "Authorization: Bearer ${gcloud auth print-access-token}" -X POST --data-raw '{"overrides": {"containerOverrides": [{"args": ["appV3", "appV4"], "env": [{"name": "app_version", "value": "V3"}], "clearArgs": "FALSE"}]}}https://us-central1-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/%7BPROJECT-ID%7D/jobs/p...

Below is the cloud run job API reference, which has instruction about overriding cloud run job arguments & environment variables via REST API.

https://cloud.google.com/run/docs/reference/rest/v1/namespaces.jobs/run 

Thank You!

View solution in original post

2 REPLIES 2

Hi @keerthi17v,

Welcome to Google Cloud Community!

As of this writing, REST API command in overriding Cloud Run job configuration is not yet available. You only perform this function through console, command line, or client libraries. You may check this documentation on overrding job configuration for a specific execution.

I would suggest filing this one as a feature request so that our engineers could take a look at this. We don't have a specific ETA on this one but you can keep track of its progress once the ticket has been created.

Hope this helps.

Hi @robertcarlos,

Thanks for your response on my query,

We can override the arguments and environment variables of cloud run job via REST API by passing the request JSON when execute the job. please find below the JSON value I passed. its working as expected.

JSON Value:

{"overrides": {"containerOverrides": [{"args": ["appV3", "appV4"], "env": [{"name": "app_version", "value": "V3"}], "clearArgs": "FALSE"}]}}

command:
curl -H "Content-Type: application/json" -H "Authorization: Bearer ${gcloud auth print-access-token}" -X POST --data-raw '{"overrides": {"containerOverrides": [{"args": ["appV3", "appV4"], "env": [{"name": "app_version", "value": "V3"}], "clearArgs": "FALSE"}]}}https://us-central1-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/%7BPROJECT-ID%7D/jobs/p...

Below is the cloud run job API reference, which has instruction about overriding cloud run job arguments & environment variables via REST API.

https://cloud.google.com/run/docs/reference/rest/v1/namespaces.jobs/run 

Thank You!