Debug Cloud Run Build Failures | Generated by AI

Home 2026.02

Question: The gcloud run deploy command failed with “Build failed; check build logs for details” and a traceback – how to find and fix the issue?

Answer:

Your deployment failed during the Cloud Build phase (triggered automatically by --source .), which handles building the container image from your source code and Dockerfile.

The key message is: “Build failed; check build logs for details” — this means the actual error (e.g. Maven compile failure, missing dependency, wrong Dockerfile instruction, permission issue, or timeout) is in the Cloud Build logs, not in the short gcloud output.

Step 1: Find the Build Logs (Quickest Ways)

  1. In the Google Cloud Console (easiest – recommended first):
    • Go to: https://console.cloud.google.com/cloud-build/builds?project=YOUR-PROJECT-ID
    • Look at the Build history list (sort by most recent).
    • Find the latest build for your service (blog-server); it usually shows as “FAILED” or has a red status.
    • Click on it → you’ll see detailed step-by-step logs.
    • Scroll through steps (especially the Maven/build step or Dockerfile execution) to find red error lines (e.g. “Compilation failure”, “Could not resolve dependencies”, “COPY failed”, etc.).
    • The console often shows a direct link like:
      “Logs are available at https://console.cloud.google.com/cloud-build/builds/abc123-xyz?project=…”
      (gcloud sometimes prints this before failing – check your terminal scrollback).
  2. Using gcloud CLI:
    • List recent builds to get the BUILD_ID (the most recent failed one):
      gcloud builds list --limit=5 --filter="status=FAILURE"
      
      • Look for the ID (long hex string like abcdef12-3456-...) and trigger/source info matching your deploy.
    • View full logs for that build:
      gcloud builds log BUILD_ID_HERE
      
      • Add --stream if you want real-time (but since it’s failed, normal is fine).
      • Or pipe to less/grep:
        gcloud builds log BUILD_ID_HERE | less
        gcloud builds log BUILD_ID_HERE | grep -i error
        

Step 2: Common Causes & Fixes for Java/Spring Boot + Dockerfile Projects

Once you see the logs, match against these frequent issues:

Since source deploy is failing, switch to manual build + deploy (you control the build locally):

  1. Build & test locally:
    docker build -t blog-server:test .
    docker run -p 8080:8080 -e PORT=8080 blog-server:test
    

    → Fix any errors here first.

  2. Tag & push:
    IMAGE="asia-southeast1-docker.pkg.dev/YOUR-PROJECT-ID/my-repo/blog-server:latest"
    docker build -t $IMAGE .
    gcloud auth configure-docker asia-southeast1-docker.pkg.dev
    docker push $IMAGE
    
  3. Deploy image directly:
    gcloud run deploy blog-server \
      --image $IMAGE \
      --region asia-southeast1 \
      --allow-unauthenticated \
      --port 8080 \
      --memory 1Gi
    

This skips the remote source upload/build entirely.

After checking logs, reply here with the specific error message from the build logs (e.g. the red part) — I can help pinpoint the exact fix.

References:


Back Donate