windows – Google Cloud Console

@echo off

REM Define the project ID and project name variables
set PROJECT_ID=new_test_project_from_gcloud
set PROJECT_NAME="New test project from Gcloud"

REM Log in to Google Cloud
echo Logging in to Google Cloud...
gcloud auth login

REM Pause to allow user to complete login
echo Please complete the login process in the browser, then press any key to continue...
pause

REM Check if login was successful
if %errorlevel% neq 0 (
    echo Failed to login
    exit /b %errorlevel%
)

REM Check if the project ID is available
echo Checking if the project ID %PROJECT_ID% is available...
gcloud projects describe %PROJECT_ID% >nul 2>&1

if %errorlevel% equ 0 (
    echo Project ID %PROJECT_ID% is already in use.
    exit /b 1
)

REM Create a new Google Cloud project
echo Creating a new Google Cloud project with ID: %PROJECT_ID% and Name: %PROJECT_NAME%...
gcloud projects create %PROJECT_ID% --name=%PROJECT_NAME% --verbosity=debug

REM Check if the project was created successfully
if %errorlevel% neq 0 (
    echo Failed to create project %PROJECT_ID%
    exit /b %errorlevel%
)

REM Set the newly created project as the active project
echo Setting the newly created project as the active project...
gcloud config set project %PROJECT_ID%

REM Verify the active project
echo Verifying the active project...
gcloud config list project

REM List all projects to verify
echo Listing all projects...
gcloud projects list

This code always terminate after the login stage. It return that the login was successful, but the line after it never runs

I tried to see if an error occurred, but there is none.

Read more here: Source link