Gcloud Login With Service Account Repack Info
To prove it, I ran:
: Ensure the account has the necessary permissions (e.g., roles/viewer or roles/editor ) to perform its intended tasks. Generate a Key File : Select your service account and go to the Keys tab. Click Add Key > Create new key .
before_script: - echo $GCP_SERVICE_ACCOUNT_KEY > /tmp/gcp-key.json - gcloud auth activate-service-account --key-file=/tmp/gcp-key.json - gcloud config set project $GCP_PROJECT_ID gcloud login with service account
./gcloud-sa-login.sh -k ./my-key.json -p my-project -v
Options: -k, --key-file PATH Service account JSON key file (required) -p, --project ID GCP project ID (optional) -v, --verbose Enable verbose output --no-set-active Don't set as active account -h, --help Show this help message To prove it, I ran: : Ensure the
if [[ -n "$PROJECT_ID" ]]; then GCLOUD_CMD="$GCLOUD_CMD --project=$PROJECT_ID" fi
# Check active account gcloud auth list
RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color
gcloud auth list --filter="status=ACTIVE" before_script: - echo $GCP_SERVICE_ACCOUNT_KEY >
if $VERBOSE; then log_info "Running: $GCLOUD_CMD" set -x fi