@@ -294,6 +294,18 @@ func runGroupTask(
294294 if feats := enabledFeaturesForProject (cfg , st , projName , proj ); len (feats ) > 0 {
295295 span .SetAttributes (attribute .StringSlice ("gitte.features" , feats ))
296296 }
297+ if env := injectedEnv (cfg , st , projName , proj ); len (env ) > 0 {
298+ keys := make ([]string , 0 , len (env ))
299+ for k := range env {
300+ keys = append (keys , k )
301+ }
302+ sort .Strings (keys )
303+ kvs := make ([]string , 0 , len (keys ))
304+ for _ , k := range keys {
305+ kvs = append (kvs , k + "=" + env [k ])
306+ }
307+ span .SetAttributes (attribute .StringSlice ("gitte.env" , kvs ))
308+ }
297309 defer func () {
298310 if err != nil {
299311 span .RecordError (err )
@@ -367,16 +379,7 @@ func emitTaskPreamble(
367379 emit (" cmd: " + strings .Join (cmds , " " ))
368380
369381 // Collect only the vars gitte injects (not all of os.Environ).
370- injected := make (map [string ]string )
371- for k , v := range proj .Env {
372- injected [k ] = v
373- }
374- for k , v := range config .ResolveEnvWhen (proj .EnvWhen , runtime .GOARCH ) {
375- injected [k ] = v
376- }
377- for k , v := range extraEnvForProject (cfg , st , projName , proj ) {
378- injected [k ] = v
379- }
382+ injected := injectedEnv (cfg , st , projName , proj )
380383 if len (injected ) > 0 {
381384 keys := make ([]string , 0 , len (injected ))
382385 for k := range injected {
@@ -391,6 +394,23 @@ func emitTaskPreamble(
391394 }
392395}
393396
397+ // injectedEnv returns the env vars gitte injects for a project's task — project
398+ // env, arch-conditional env_when, and enabled feature-gate env — excluding the
399+ // inherited process environment (os.Environ).
400+ func injectedEnv (cfg * config.GitteConfig , st * state.GitteState , projName string , proj config.ProjectConfig ) map [string ]string {
401+ injected := make (map [string ]string )
402+ for k , v := range proj .Env {
403+ injected [k ] = v
404+ }
405+ for k , v := range config .ResolveEnvWhen (proj .EnvWhen , runtime .GOARCH ) {
406+ injected [k ] = v
407+ }
408+ for k , v := range extraEnvForProject (cfg , st , projName , proj ) {
409+ injected [k ] = v
410+ }
411+ return injected
412+ }
413+
394414// enabledFeaturesForProject returns the sorted names of feature gates that are
395415// enabled and in scope for the given project (the gates that actually inject
396416// env into the project's tasks).
0 commit comments