1👍
Use Method:prjects.builds.list API, you could use this API to get all list, and also you can query pageSize to get the number of results in the list.
When you get response from the API, you can just do what you want with your $BUILD_ID
I hope this information above is helpful.
0👍
Your cloudbuild.yaml
file can pass substitution variables into a container you are deploying by using the set-env-vars
flag.
# Deploy container image to Cloud Run
- id: "deploy"
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- '${_SERVICE_NAME}'
- '--image'
- 'gcr.io/$PROJECT_ID/${_SERVICE_NAME}:$COMMIT_SHA'
- '--platform=managed'
- '--region=${_DEPLOY_REGION}'
- '--vpc-connector redis'
- '--set-env-vars REDISHOST=${_REDIS_HOST},REDISPORT=${_REDIS_PORT},BUILD_ID=$BUILD_ID'
Here we pass _REDIS_HOST
and _REDIS_PORT
and BUILD_ID
into the container as REDISHOST
, REDISPORT
and BUILD_ID
.
We can now read these within python like so:
settings.py file:
...
redis_host = os.environ.get('REDISHOST', 'localhost')
redis_port = int(os.environ.get('REDISPORT', 6379))
build_id = int(os.environ.get('BUILD_ID', None))
- [Answered ]-How to write custom obj_create and obj_update in django tasty pie
- [Answered ]-Django User's Sessions getting Mixed.
Source:stackexchange.com