@@ -197,9 +197,24 @@ func updateTaskRunProvenance(taskRun *v1.TaskRun, stepName string, stepIndex int
197197
198198// GetStepActionsData extracts the StepActions and merges them with the inlined Step specification.
199199func GetStepActionsData (ctx context.Context , taskSpec v1.TaskSpec , taskRun * v1.TaskRun , tekton clientset.Interface , k8s kubernetes.Interface , requester remoteresource.Requester ) ([]v1.Step , error ) {
200- // If there are no step-ref to resolve, return immediately
200+ steps := make ([]v1.Step , len (taskSpec .Steps ))
201+
202+ // Init step states and known step states indexes lookup map
203+ if taskRun .Status .Steps == nil {
204+ taskRun .Status .Steps = []v1.StepState {}
205+ }
206+ stepStatusIndex := make (map [string ]int , len (taskRun .Status .Steps ))
207+ for i , stepState := range taskRun .Status .Steps {
208+ stepStatusIndex [stepState .Name ] = i
209+ }
210+
211+ // If there are no step-ref to resolve, return immediately with nil provenance
201212 if ! hasStepRefs (& taskSpec ) {
202- return taskSpec .Steps , nil
213+ for i , step := range taskSpec .Steps {
214+ steps [i ] = step
215+ updateTaskRunProvenance (taskRun , step .Name , i , nil , stepStatusIndex ) // create StepState with nil provenance
216+ }
217+ return steps , nil
203218 }
204219
205220 // Phase 1: Concurrently resolve all StepActions
@@ -229,15 +244,6 @@ func GetStepActionsData(ctx context.Context, taskSpec v1.TaskSpec, taskRun *v1.T
229244 }
230245
231246 // Phase 2: Sequentially merge results into the final step list and update status
232- if taskRun .Status .Steps == nil {
233- taskRun .Status .Steps = []v1.StepState {}
234- }
235- stepStatusIndex := make (map [string ]int , len (taskRun .Status .Steps ))
236- for i , stepState := range taskRun .Status .Steps {
237- stepStatusIndex [stepState .Name ] = i
238- }
239-
240- steps := make ([]v1.Step , len (taskSpec .Steps ))
241247 for i , step := range taskSpec .Steps {
242248 if step .Ref == nil {
243249 steps [i ] = step
0 commit comments