In hooks scripts in app.json (prebuild/postbuild/precreate/postcreate) we can call some shell commands in the context of the current ephemeral Cloud Shell, but it looks like there's no GCP project id set there. Though the project should have been selected on the first stage of the startup script of the VM, so at the moment of hooks execution it's known.
So, the question is how can I access the current selected GCP project id in a hook script?
And regardless of this, a suggestion - set the current project id via gcloud (gcloud config set project xxx), so it could be used implicitly.
In hooks scripts in app.json (prebuild/postbuild/precreate/postcreate) we can call some shell commands in the context of the current ephemeral Cloud Shell, but it looks like there's no GCP project id set there. Though the project should have been selected on the first stage of the startup script of the VM, so at the moment of hooks execution it's known. So, the question is how can I access the current selected GCP project id in a hook script?
And regardless of this, a suggestion - set the current project id via gcloud (
gcloud config set project xxx
), so it could be used implicitly.