Skip to content

Commit

Permalink
feat(render): print build log if failed
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Igrychev <alexey.igrychev@flant.com>
  • Loading branch information
alexey-igrychev committed Jul 26, 2022
1 parent 8794cbc commit 8007487
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions cmd/werf/render/render.go
@@ -1,6 +1,7 @@
package render

import (
"bytes"
"context"
"fmt"
"io"
Expand Down Expand Up @@ -305,19 +306,24 @@ func runRender(ctx context.Context) error {
defer conveyorWithRetry.Terminate()

if err := conveyorWithRetry.WithRetryBlock(ctx, func(c *build.Conveyor) error {
buf := new(bytes.Buffer)
bufLogger := logboek.NewLogger(buf, buf)
ctxWithBufLogger := logboek.NewContext(ctx, bufLogger)

var buildErr error
if *commonCmdData.SkipBuild {
shouldBeBuiltOptions, err := common.GetShouldBeBuiltOptions(&commonCmdData, giterminismManager, werfConfig)
if err != nil {
return err
}

if err := c.ShouldBeBuilt(ctx, shouldBeBuiltOptions); err != nil {
return err
}
buildErr = c.ShouldBeBuilt(ctxWithBufLogger, shouldBeBuiltOptions)
} else {
if err := c.Build(ctx, buildOptions); err != nil {
return err
}
buildErr = c.Build(ctxWithBufLogger, buildOptions)
}
if buildErr != nil {
fmt.Println(buf.String())
return buildErr
}

imagesInfoGetters = c.GetImageInfoGetters(image.InfoGetterOptions{CustomTagFunc: useCustomTagFunc})
Expand Down

0 comments on commit 8007487

Please sign in to comment.