@@ -90,7 +90,7 @@ func processActionVariables(a *sdk.Action, parent *sdk.Action, jobParameters []s
9090 // replaces placeholder in all children recursively
9191 for i := range a .Actions {
9292 if err := processActionVariables (& a .Actions [i ], a , jobParameters , secrets ); err != nil {
93- return nil
93+ return err
9494 }
9595 }
9696
@@ -109,7 +109,7 @@ func (w *CurrentWorker) replaceVariablesPlaceholder(a *sdk.Action, params []sdk.
109109 return nil
110110}
111111
112- func (w * CurrentWorker ) runJob (ctx context.Context , a * sdk.Action , jobID int64 , secrets []sdk.Variable ) ( sdk.Result , error ) {
112+ func (w * CurrentWorker ) runJob (ctx context.Context , a * sdk.Action , jobID int64 , secrets []sdk.Variable ) sdk.Result {
113113 log .Info (ctx , "runJob> start job %s (%d)" , a .Name , jobID )
114114 defer func () { log .Info (ctx , "runJob> job %s (%d)" , a .Name , jobID ) }()
115115
@@ -124,7 +124,7 @@ func (w *CurrentWorker) runJob(ctx context.Context, a *sdk.Action, jobID int64,
124124 if err := w .updateStepStatus (ctx , jobID , jobStepIndex , sdk .StatusBuilding ); err != nil {
125125 jobResult .Status = sdk .StatusFail
126126 jobResult .Reason = fmt .Sprintf ("Cannot update step (%d) status (%s): %v" , jobStepIndex , sdk .StatusBuilding , err )
127- return jobResult , err
127+ return jobResult
128128 }
129129 var stepResult = sdk.Result {
130130 Status : sdk .StatusNeverBuilt ,
@@ -163,7 +163,7 @@ func (w *CurrentWorker) runJob(ctx context.Context, a *sdk.Action, jobID int64,
163163 if err := w .updateStepStatus (ctx , jobID , jobStepIndex , stepResult .Status ); err != nil {
164164 jobResult .Status = sdk .StatusFail
165165 jobResult .Reason = fmt .Sprintf ("Cannot update step (%d) status (%s): %v" , jobStepIndex , sdk .StatusBuilding , err )
166- return jobResult , err
166+ return jobResult
167167 }
168168 }
169169
@@ -178,7 +178,7 @@ func (w *CurrentWorker) runJob(ctx context.Context, a *sdk.Action, jobID int64,
178178 if nCriticalFailed > 0 {
179179 jobResult .Status = sdk .StatusFail
180180 }
181- return jobResult , nil
181+ return jobResult
182182}
183183
184184func (w * CurrentWorker ) runAction (ctx context.Context , a sdk.Action , jobID int64 , secrets []sdk.Variable , actionName string ) sdk.Result {
@@ -459,7 +459,7 @@ func (w *CurrentWorker) setupKeysDirectory(ctx context.Context, jobInfo sdk.Work
459459 return kdFile , kdAbs , nil
460460}
461461
462- func (w * CurrentWorker ) ProcessJob (jobInfo sdk.WorkflowNodeJobRunData ) (sdk.Result , error ) {
462+ func (w * CurrentWorker ) ProcessJob (jobInfo sdk.WorkflowNodeJobRunData ) (res sdk.Result ) {
463463 ctx := w .currentJob .context
464464 t0 := time .Now ()
465465
@@ -472,6 +472,8 @@ func (w *CurrentWorker) ProcessJob(jobInfo sdk.WorkflowNodeJobRunData) (sdk.Resu
472472 defer cancel ()
473473
474474 ctx = workerruntime .SetJobID (ctx , jobInfo .NodeJobRun .ID )
475+ ctx = workerruntime .SetStepOrder (ctx , 0 )
476+
475477 // start logger routine with a large buffer
476478 w .logger .logChan = make (chan sdk.Log , 100000 )
477479 go func () {
@@ -484,13 +486,16 @@ func (w *CurrentWorker) ProcessJob(jobInfo sdk.WorkflowNodeJobRunData) (sdk.Resu
484486 log .Error (ctx , "processJob> Drain logs error: %v" , err )
485487 }
486488 }()
489+ defer func () {
490+ log .Error (ctx , "processJob> Status: %s | Reason: %s" , res .Status , res .Reason )
491+ }()
487492
488493 wdFile , wdAbs , err := w .setupWorkingDirectory (ctx , jobInfo )
489494 if err != nil {
490495 return sdk.Result {
491496 Status : sdk .StatusFail ,
492497 Reason : fmt .Sprintf ("Error: unable to setup workfing directory: %v" , err ),
493- }, err
498+ }
494499 }
495500 ctx = workerruntime .SetWorkingDirectory (ctx , wdFile )
496501 log .Debug ("processJob> Setup workspace - %s" , wdFile .Name ())
@@ -500,7 +505,7 @@ func (w *CurrentWorker) ProcessJob(jobInfo sdk.WorkflowNodeJobRunData) (sdk.Resu
500505 return sdk.Result {
501506 Status : sdk .StatusFail ,
502507 Reason : fmt .Sprintf ("Error: unable to setup keys directory: %v" , err ),
503- }, err
508+ }
504509 }
505510 ctx = workerruntime .SetKeysDirectory (ctx , kdFile )
506511 log .Debug ("processJob> Setup key directory - %s" , kdFile .Name ())
@@ -527,8 +532,8 @@ func (w *CurrentWorker) ProcessJob(jobInfo sdk.WorkflowNodeJobRunData) (sdk.Resu
527532 if err := processVariablesAndParameters (& jobInfo .NodeJobRun .Job .Action , jobParameters , jobInfo .Secrets ); err != nil {
528533 return sdk.Result {
529534 Status : sdk .StatusFail ,
530- Reason : fmt .Sprintf ("Error: cannot process job %s parameters " , jobInfo .NodeJobRun .Job .Action .Name ),
531- }, err
535+ Reason : fmt .Sprintf ("unable to process job %s: %v " , jobInfo .NodeJobRun .Job .Action .Name , err ),
536+ }
532537 }
533538
534539 // Add secrets as string or password in ActionBuild.Args
@@ -544,7 +549,7 @@ func (w *CurrentWorker) ProcessJob(jobInfo sdk.WorkflowNodeJobRunData) (sdk.Resu
544549
545550 w .currentJob .params = jobParameters
546551
547- res , err : = w .runJob (ctx , & jobInfo .NodeJobRun .Job .Action , jobInfo .NodeJobRun .ID , jobInfo .Secrets )
552+ res = w .runJob (ctx , & jobInfo .NodeJobRun .Job .Action , jobInfo .NodeJobRun .ID , jobInfo .Secrets )
548553
549554 if len (res .NewVariables ) > 0 {
550555 log .Debug ("processJob> new variables: %v" , res .NewVariables )
@@ -563,5 +568,5 @@ func (w *CurrentWorker) ProcessJob(jobInfo sdk.WorkflowNodeJobRunData) (sdk.Resu
563568 log .Error (ctx , "Cannot remove basedir content: %s" , err )
564569 }
565570
566- return res , err
571+ return res
567572}
0 commit comments