Skip to content

Quote BRANCH and APP_METADATA build args in Makefile.pf9 - #3

Merged
PF9-kunal merged 1 commit into
mainfrom
private/kunal/dockerfile-fix
Nov 8, 2026
Merged

PF9-kunal merged 1 commit into
mainfrom
private/kunal/dockerfile-fix

Conversation

@PF9-kunal

Copy link
Copy Markdown
Collaborator

Problem

Builds on the default branch fail immediately:

/bin/sh: default: No such file or directory
Exit code 2 (Step: Build and push ... container)

Seen in build #15.

Cause

TeamCity sets TEAMCITY_BUILD_BRANCH to the literal string <default> when a build runs on the VCS root's default branch. Makefile.pf9 passed that straight through unquoted:

--build-arg BRANCH=$(BRANCH) \

which expands to:

docker build ... --build-arg BRANCH=<default> ...

The shell reads < and > as redirection operators, tries to open a file named default for input, and aborts before docker build ever runs.

Builds on private/* branches were unaffected, because those branch names contain no shell metacharacters — which is why this only surfaced once the default branch was built.

Fix

Quote the two args whose values are not guaranteed to be simple tokens:

--build-arg BRANCH='$(BRANCH)' \
--build-arg APP_METADATA='$(APP_METADATA)' \

APP_METADATA is included for the same reason — it carries JSON, whose braces, spaces and quotes break identically once it is non-empty.

The remaining args (GO_VERSION, GOOS, GOARCH, CGO_ENABLED, VERSION, BUILD_ID) are left alone; their values are always simple tokens.

Verification

Reproduced and confirmed fixed locally by simulating the exact TeamCity value:

$ TEAMCITY_BUILD_BRANCH='<default>' PF9_VERSION=2026.12.0 BUILD_NUMBER=16 \
    make -f Makefile.pf9 -n build

        --build-arg BRANCH='<default>' \
        --build-arg APP_METADATA='' \

The generated command now parses cleanly instead of aborting the step.

🤖 Generated with Claude Code

Builds of the default branch failed with:

    /bin/sh: default: No such file or directory
    Exit code 2 (Step: Build and push ... container)

TeamCity sets TEAMCITY_BUILD_BRANCH to the literal string "<default>"
when a build runs on the VCS root's default branch. That value reached
the docker build line unquoted, so the shell parsed "<" and ">" as
redirection operators and tried to open a file named "default" instead
of passing the value through.

APP_METADATA gets the same treatment: it carries JSON, whose braces,
spaces and quotes break the same way once it is non-empty.

The remaining build args (GO_VERSION, GOOS, BUILD_ID, ...) are left as
they are — their values are always simple tokens.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@PF9-kunal
PF9-kunal merged commit 6480631 into main Nov 8, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant