Gcloud command line get default project_id

前端 未结 5 573
野的像风
野的像风 2021-02-01 13:13

I\'m looking for a one-liner to get the default project id

with gcloud config list core/project give me

Your active configuration is: [defau         


        
5条回答
  •  执念已碎
    2021-02-01 13:34

    Thanks to comment from Tim Swast above, I was able to use export PROJECT_ID=$(gcloud config get-value project) to get the project ID.

    Running gcloud config get-value project prints the following on screen:

    Your active configuration is: [default]
    
    my-project-id
    

    You can also run gcloud config get-value project 2> /dev/null to print just the project ID and suppress other warnings/errors.

提交回复
热议问题