fix(CI): bytt metadata-token til gcloud auth print-identity-token i smoke-test

This commit is contained in:
chrischristiansen-glitch 2026-06-10 09:21:17 +02:00
parent 3358f1ee22
commit 4e12144152

View File

@ -58,7 +58,7 @@ steps:
- '--quiet' - '--quiet'
# Steg 5: Smoke test — verifiser at agenten svarer etter deploy # Steg 5: Smoke test — verifiser at agenten svarer etter deploy
# CI6-lærdom: identity token med riktig audience, ikke access token # Bruker gcloud auth print-identity-token (fungerer i Cloud Build 2nd gen)
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk' - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
id: smoke-test id: smoke-test
waitFor: ['deploy'] waitFor: ['deploy']
@ -67,12 +67,11 @@ steps:
- '-c' - '-c'
- | - |
echo "=== Smoke Test ===" echo "=== Smoke Test ==="
TOKEN=$(curl -sf \ TOKEN=$$(gcloud auth print-identity-token \
-H "Metadata-Flavor: Google" \ --audiences="https://${_CLOUD_RUN_URL}") \
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?audience=https://${_CLOUD_RUN_URL}&format=full") \
|| { echo "❌ Kunne ikke hente identity token"; exit 1; } || { echo "❌ Kunne ikke hente identity token"; exit 1; }
RESPONSE=$(curl -sf \ RESPONSE=$$(curl -sf \
-H "Authorization: Bearer $$TOKEN" \ -H "Authorization: Bearer $$TOKEN" \
-H "x-goog-authenticated-user-email: accounts.google.com:ci-test@vauco.no" \ -H "x-goog-authenticated-user-email: accounts.google.com:ci-test@vauco.no" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \