Repository navigation
Quote BRANCH and APP_METADATA build args in Makefile.pf9 - #3
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Builds on the default branch fail immediately:
Seen in build #15.
Cause
TeamCity sets
TEAMCITY_BUILD_BRANCHto the literal string<default>when a build runs on the VCS root's default branch.Makefile.pf9passed that straight through unquoted:which expands to:
The shell reads
<and>as redirection operators, tries to open a file nameddefaultfor input, and aborts beforedocker buildever 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:
APP_METADATAis 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:
The generated command now parses cleanly instead of aborting the step.
🤖 Generated with Claude Code