#Getting the contents of file after a failed WithExec

1 messages · Page 1 of 1 (latest)

mystic thorn
#

I have a step which produces ungodly amounts of logs (Sonar Cloud) which I pipe to a file so that we don't produce MB of logs on every build. What I want to do is cat the file when an error occurs so we can dig deeper.

I'm getting a panic about a nil f in the psuedo code below. Is something like this possible? (getting the file contents written to by a failed WithExec)

(unfortunately, I am unable to reproduce this locally and it only fails in CI... 💢 )


s, err := sonar.WithDirectory(...).WithExec("sonar-scanner ... > sonar.txt").Sync(ctx)
if err != nil {
  f := s.File("sonar.txt")
  c := f.Contents(ctx)
  fmt.Println(c)
}