diff --git a/build/build.go b/build/build.go index 0db42f95..3c7743ed 100644 --- a/build/build.go +++ b/build/build.go @@ -510,10 +510,12 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s for k, v := range printRes { rr.ExporterResponse[k] = string(v) } - rr.ExporterResponse["buildx.build.ref"] = buildRef - if node.Driver.HistoryAPISupported(ctx) { - if err := setRecordProvenance(ctx, c, rr, so.Ref, opt.ProvenanceResponseMode, pw); err != nil { - return err + if opt.PrintFunc == nil { + rr.ExporterResponse["buildx.build.ref"] = buildRef + if node.Driver.HistoryAPISupported(ctx) { + if err := setRecordProvenance(ctx, c, rr, so.Ref, opt.ProvenanceResponseMode, pw); err != nil { + return err + } } } diff --git a/tests/bake.go b/tests/bake.go index 39b9c9a9..c89d290d 100644 --- a/tests/bake.go +++ b/tests/bake.go @@ -1271,6 +1271,6 @@ target "default" {} } var md mdT require.NoError(t, json.Unmarshal(dt, &md), dt) - require.NotEmpty(t, md.Default.BuildRef) + require.Empty(t, md.Default.BuildRef) require.Len(t, md.Default.ResultJSON.Warnings, 3) } diff --git a/tests/build.go b/tests/build.go index 3a22a592..54792cb5 100644 --- a/tests/build.go +++ b/tests/build.go @@ -1228,7 +1228,7 @@ COPy --from=base \ } var md mdT require.NoError(t, json.Unmarshal(dt, &md), dt) - require.NotEmpty(t, md.BuildRef) + require.Empty(t, md.BuildRef) require.Len(t, md.ResultJSON.Warnings, 3) }) }