Search code examples
google-cloud-platformgoogle-cloud-rungoogle-cloud-run-jobs

Variable to retrieve job ID in Google Cloud Run using Java


I'm working with Google Cloud Run and I need to retrieve the unique job ID of an execution from my Java application. I've reviewed the Google Cloud Run documentation but haven't found a specific environment variable that provides this ID directly.

Is there a standard environment variable in Google Cloud Run that I can use from my Java application to retrieve the job ID of the current execution?

I came across 'K_JOB_ID' as a potential candidate for this purpose — can anyone confirm if 'K_JOB_ID' is indeed the recommended variable for fulfilling my requirement?

If not, are there any recommended practices or common approaches for handling and tracking job IDs in this environment?

Thank you in advance for any guidance or suggestions.

I came across 'K_JOB_ID' as a potential candidate for this purpose. Can anyone confirm if 'K_JOB_ID' is actually the recommended variable to fulfill my requirement of retrieving the execution id of job?


Solution

  • guillaume blaquiere The K_JON_ID is not documented and I fear it can disapear anytime. I recommend to use the CLOUD_RUN_EXECUTION to have a unique ID of your Cloud Run Job execution (I understand you use the Job version of Cloud Run in your description, but it's only an asumption). Here the doc: cloud.google.com/run/docs/container-contract#jobs-env-vars