diff --git a/imagebuildah/executor.go b/imagebuildah/executor.go index 5f23a5826a2..7edba08d994 100644 --- a/imagebuildah/executor.go +++ b/imagebuildah/executor.go @@ -751,9 +751,11 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image } headingArgs := argsMapToSlice(stage.Builder.HeadingArgs) userArgs := argsMapToSlice(stage.Builder.Args) + populatedBuiltInBuildArgs := argsMapToSlice(imagebuilder.BuiltInBuildArgs) // append heading args so if --build-arg key=value is not // specified but default value is set in Containerfile // via `ARG key=value` so default value can be used. + userArgs = append(userArgs, populatedBuiltInBuildArgs...) userArgs = append(headingArgs, userArgs...) baseWithArg, err := imagebuilder.ProcessWord(base, userArgs) if err != nil { diff --git a/tests/bud.bats b/tests/bud.bats index 064381bc88b..055adfdeab7 100644 --- a/tests/bud.bats +++ b/tests/bud.bats @@ -266,6 +266,10 @@ symlink(subdir)" run_buildah build --platform linux/$myarch/$myvariant $WITH_POLICY_JSON -t test -f $BUDFILES/base-with-arg/Containerfile expect_output --substring "This is built for $myarch" + + # Should work without platform string as well + run_buildah build $WITH_POLICY_JSON -t test -f $BUDFILES/base-with-arg/Containerfile + expect_output --substring "This is built for $myarch" } @test "build with basename resolving user arg" {