File size: 1,919 Bytes
d61821a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff --git a/functions/concrete/builder/builder.go b/functions/concrete/builder/builder.go
index 89828cb4..b480902a 100644
--- a/functions/concrete/builder/builder.go
+++ b/functions/concrete/builder/builder.go
@@ -60,6 +60,7 @@ func Build(job spec.Job, vars variables.Provider, options ...Option) ([]byte, er
 	config.AfterScriptIgnoreErrors = variables.DefaultBool(
 		b.variables, "AFTER_SCRIPT_IGNORE_ERRORS", true,
 	)
+	config.TraceSections = b.meta.Features.TraceSections
 
 	config.CacheArchive, err = b.buildCacheArchive()
 	if err != nil {
diff --git a/functions/concrete/run/runner.go b/functions/concrete/run/runner.go
index 5088598c..8e50b3c3 100644
--- a/functions/concrete/run/runner.go
+++ b/functions/concrete/run/runner.go
@@ -49,6 +49,7 @@ type Config struct {
 	ScriptTimeout           time.Duration `json:"script_timeout,omitempty"`
 	AfterScriptTimeout      time.Duration `json:"after_script_timeout,omitempty"`
 	AfterScriptIgnoreErrors bool          `json:"after_script_ignore_errors,omitempty"`
+	TraceSections           bool          `json:"trace_sections,omitempty"`
 	ID                      int64         `json:"id,omitempty"`
 	Token                   string        `json:"token,omitempty"`
 	BaseURL                 string        `json:"base_url,omitempty"`
@@ -368,8 +369,10 @@ func (r *Runner) withTimeout(parent context.Context, d time.Duration) (context.C
 }
 
 func (r *Runner) section(ctx context.Context, name string, fn func(context.Context, *env.Env) error) error {
-	fmt.Fprintf(r.env.Stdout, "section_start:%d:%s\r\033[0K", time.Now().Unix(), name)
-	defer fmt.Fprintf(r.env.Stdout, "section_end:%d:%s\r\033[0K", time.Now().Unix(), name)
+	if r.config.TraceSections {
+		fmt.Fprintf(r.env.Stdout, "section_start:%d:%s\r\033[0K", time.Now().Unix(), name)
+		defer fmt.Fprintf(r.env.Stdout, "section_end:%d:%s\r\033[0K", time.Now().Unix(), name)
+	}
 
 	return fn(ctx, r.env)
 }