Skip to content

Show logs when a build fails before the "build" phase starts #95

@ipmb

Description

@ipmb

We only stream build and test (aka postbuild) logs in the client, but there are scenarios where a build could fail in other phases. Prebuild is a common one when app.json or apppack.toml are not properly formatted. In those scenarios, we should output the relevant logs so users can see what happened.

example prebuild failure raw logs
[Container] 2025/07/17 20:53:39.016370 Running on CodeBuild On-demand
[Container] 2025/07/17 20:53:39.016385 Waiting for agent ping
[Container] 2025/07/17 20:53:40.221146 Waiting for DOWNLOAD_SOURCE
[Container] 2025/07/17 20:53:41.794309 Phase is DOWNLOAD_SOURCE
[Container] 2025/07/17 20:53:41.796088 CODEBUILD_SRC_DIR=/codebuild/output/src251170741/src/github.com/org/repo
[Container] 2025/07/17 20:53:41.796655 YAML location is /codebuild/readonly/buildspec.yml
[Container] 2025/07/17 20:53:41.801226 Setting HTTP client timeout to higher timeout for Github and GitHub Enterprise sources
[Container] 2025/07/17 20:53:41.801397 Processing environment variables
[Container] 2025/07/17 20:53:41.858424 Moving to directory /codebuild/output/src251170741/src/github.com/org/repo
[Container] 2025/07/17 20:53:41.858446 Cache is not defined in the buildspec
[Container] 2025/07/17 20:53:41.891646 Skip cache due to: no paths specified to be cached
[Container] 2025/07/17 20:53:41.891944 Registering with agent
[Container] 2025/07/17 20:53:41.921956 Phases found in YAML: 4
[Container] 2025/07/17 20:53:41.921971  BUILD: 1 commands
[Container] 2025/07/17 20:53:41.921976  INSTALL: 4 commands
[Container] 2025/07/17 20:53:41.921980  POST_BUILD: 1 commands
[Container] 2025/07/17 20:53:41.921983  PRE_BUILD: 1 commands
[Container] 2025/07/17 20:53:41.922418 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2025/07/17 20:53:41.922430 Phase context status code:  Message: 
[Container] 2025/07/17 20:53:42.521431 Entering phase INSTALL
[Container] 2025/07/17 20:53:42.553646 Running command if [ -z "$CODEBUILD_START_TIME" ]; then exit 0; fi
[Container] 2025/07/17 20:53:42.560506 Running command echo "Starting Docker daemon..."
Starting Docker daemon...
[Container] 2025/07/17 20:53:42.568107 Running command nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 --registry-mirror=https://registry.apppackcdn.net &> /var/lib/docker.log &
[Container] 2025/07/17 20:53:42.573477 Running command for i in $(seq 1 10); do docker info > /dev/null 2>&1 && break || sleep 0.5; done
[Container] 2025/07/17 20:53:46.329196 Phase complete: INSTALL State: SUCCEEDED
[Container] 2025/07/17 20:53:46.329218 Phase context status code:  Message: 
[Container] 2025/07/17 20:53:46.361218 Entering phase PRE_BUILD
[Container] 2025/07/17 20:53:46.362687 Running command apppack-builder prebuild
20:53:46 ERR failed to parse app.json error="invalid character '/' after object key:value pair"
20:53:46 FTL Error error="invalid character '/' after object key:value pair"
[Container] 2025/07/17 20:53:46.379706 Command did not exit successfully apppack-builder prebuild exit status 1
[Container] 2025/07/17 20:53:46.383610 Phase complete: PRE_BUILD State: FAILED
[Container] 2025/07/17 20:53:46.383628 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: apppack-builder prebuild. Reason: exit status 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions