Skip to content
Snippets Groups Projects
Commit b43207f6 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat: skip GCP ADC authent when GCP_JWT is not present

Don't set GCP ADC authent when GCP_JWT is not present to preserve gitlab-ci-local with local GCP authentication
parent fba5af5e
Branches
Tags
No related merge requests found
......@@ -20,10 +20,11 @@ variables:
GCP_OIDC_PROVIDER: $[[ inputs.gcp-oidc-provider ]]
.python-gcp-adc:
- set -e
- echo -e "[\\e[1;94mINFO\\e[0m] Installing GCP authentication with env GOOGLE_APPLICATION_CREDENTIALS file"
- echo $GCP_JWT > "$CI_BUILDS_DIR/.auth_token.jwt"
- |-
- |
if [[ "$GCP_JWT" ]]
then
echo -e "[\\e[1;94mINFO\\e[0m] Installing GCP authentication with env GOOGLE_APPLICATION_CREDENTIALS file"
echo $GCP_JWT > "$CI_BUILDS_DIR/.auth_token.jwt"
cat << EOF > "$CI_BUILDS_DIR/google_application_credentials.json"
{
"type": "external_account",
......@@ -36,7 +37,10 @@ variables:
"service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${GCP_OIDC_ACCOUNT}:generateAccessToken"
}
EOF
- export GOOGLE_APPLICATION_CREDENTIALS="$CI_BUILDS_DIR/google_application_credentials.json"
export GOOGLE_APPLICATION_CREDENTIALS="$CI_BUILDS_DIR/google_application_credentials.json"
else
echo '[WARN] $GCP_JWT is not set: cannot setup Application Default Credentials (ADC) authentication'
fi
.python-base:
image: $PYTHON_IMAGE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment