Google Cloud Build CI管道连接测试数据库认证失败求助
Cloud Build CI测试步骤数据库认证失败问题
我的Google Cloud Build CI管道中,tests步骤因数据库认证错误失败,报错信息:
error: password authentication failed for user "postgres"
我确认PG_PASSWORD密钥没问题:
- 密钥仅存在一个版本
- 同一密钥版本已在生产环境成功连接同一数据库实例
- 我可通过TablePlus客户端使用该密码以
postgres用户登录并访问testing数据库
Cloud Build CI配置
steps: - id: install name: 'node:22' entrypoint: npm args: ['install'] - id: proxy-install name: 'node:22' entrypoint: sh args: - -c - | wget -O /workspace/cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.linux.386 chmod +x /workspace/cloud_sql_proxy - id: tests name: 'node:22' timeout: 600s entrypoint: sh args: - -c - | /workspace/cloud_sql_proxy -term_timeout=100s -dir=/workspace -instances=w121-cms:europe-west1:w121=tcp:5432 & sleep 2 npm run ci:test env: - 'TZ=UTC' - 'HOST=0.0.0.0' - 'LOG_LEVEL=info' - 'APP_NAME=Journey' - 'SESSION_DRIVER=memory' - 'NODE_ENV=test' - 'DB_HOST=127.0.0.1' - 'DB_PORT=5432' - 'DB_USER=postgres' - 'DB_DATABASE=testing' - 'DB_PASSWORD=$$PG_PASSWORD' - 'MAIL_FROM_ADDRESS=services@example.com' - 'MAILGUN_API_KEY=redactedredacted' - 'MAILGUN_DOMAIN=mailgun.example.com' - 'BIBLE_API_KEY=redactedredacted' - 'CLOUDINARY_API_KEY=tmp' - 'CLOUDINARY_SECRET=tmp' - 'CLOUDINARY_CLOUD_NAME=tmp' - 'CLOUDINARY_PRESET=tmp' secretEnv: ['PG_PASSWORD', 'APP_KEY'] availableSecrets: secretManager: - env: 'PG_PASSWORD' versionName: projects/$PROJECT_ID/secrets/PG_PASSWORD/versions/1 - env: 'APP_KEY' versionName: projects/$PROJECT_ID/secrets/APP_KEY/versions/1
相关日志追踪
Step #2 - "tests": c[ info ] booting application to run tests... Step #2 - "tests": 2025/02/19 14:22:39 New connection for "w121-cms:europe-west1:w121" Step #2 - "tests": 2025/02/19 14:22:39 refreshing ephemeral certificate for instance w121-cms:europe-west1:w121 Step #2 - "tests": 2025/02/19 14:22:39 Scheduling refresh of ephemeral certificate in 54m59s Step #2 - "tests": 2025/02/19 14:22:40 New connection for "w121-cms:europe-west1:w121" Step #2 - "tests": 2025/02/19 14:22:40 Instance w121-cms:europe-west1:w121 closed connection Step #2 - "tests": 2025/02/19 14:22:40 Instance w121-cms:europe-west1:w121 closed connection Step #2 - "tests": Step #2 - "tests": error: Step #2 - "tests": password Step #2 - "tests": authentication Step #2 - "tests": failed Step #2 - "tests": for Step #2 - "tests": user Step #2 - "tests": "postgres"
内容的提问来源于stack exchange,提问作者Jannie Theunissen
相关产品推荐
相关产品推荐

