@@ -94,7 +94,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
94
94
}
95
95
}
96
96
97
- postExecutor = postExecutor . Finally ( func (ctx context.Context ) error {
97
+ var stopContainerExecutor common. Executor = func (ctx context.Context ) error {
98
98
jobError := common .JobError (ctx )
99
99
var err error
100
100
if rc .Config .AutoRemove || jobError == nil {
@@ -108,30 +108,48 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
108
108
logger .Errorf ("Error while stop job container: %v" , err )
109
109
}
110
110
}
111
+ return err
112
+ }
113
+
114
+ var setJobResultExecutor common.Executor = func (ctx context.Context ) error {
115
+ jobError := common .JobError (ctx )
111
116
setJobResult (ctx , info , rc , jobError == nil )
112
117
setJobOutputs (ctx , rc )
118
+ return nil
119
+ }
113
120
114
- return err
115
- })
121
+ var setJobError = func (ctx context.Context , err error ) error {
122
+ common .SetJobError (ctx , err )
123
+ return nil
124
+ }
116
125
117
126
pipeline := make ([]common.Executor , 0 )
118
- pipeline = append (pipeline , rc .InitializeNodeTool ())
119
127
pipeline = append (pipeline , preSteps ... )
120
128
pipeline = append (pipeline , steps ... )
121
129
122
- return common .NewPipelineExecutor (info .startContainer (), common .NewPipelineExecutor (pipeline ... ).
123
- Finally (func (ctx context.Context ) error { //nolint:contextcheck
124
- var cancel context.CancelFunc
125
- if ctx .Err () == context .Canceled {
126
- // in case of an aborted run, we still should execute the
127
- // post steps to allow cleanup.
128
- ctx , cancel = context .WithTimeout (common .WithLogger (context .Background (), common .Logger (ctx )), 5 * time .Minute )
129
- defer cancel ()
130
- }
131
- return postExecutor (ctx )
132
- }).
133
- Finally (info .interpolateOutputs ()).
134
- Finally (info .closeContainer ()))
130
+ return common .NewPipelineExecutor (
131
+ common .NewFieldExecutor ("step" , "Set up job" , common .NewFieldExecutor ("stepid" , []string {"--setup-job" },
132
+ common .NewPipelineExecutor (common .NewInfoExecutor ("\u2B50 Run Set up job" ), info .startContainer (), rc .InitializeNodeTool ()).
133
+ Then (common .NewFieldExecutor ("stepResult" , model .StepStatusSuccess , common .NewInfoExecutor (" \u2705 Success - Set up job" ))).
134
+ OnError (common .NewFieldExecutor ("stepResult" , model .StepStatusFailure , common .NewInfoExecutor (" \u274C Failure - Set up job" )).ThenError (setJobError )))),
135
+ common .NewPipelineExecutor (pipeline ... ).
136
+ Finally (func (ctx context.Context ) error { //nolint:contextcheck
137
+ var cancel context.CancelFunc
138
+ if ctx .Err () == context .Canceled {
139
+ // in case of an aborted run, we still should execute the
140
+ // post steps to allow cleanup.
141
+ ctx , cancel = context .WithTimeout (common .WithLogger (context .Background (), common .Logger (ctx )), 5 * time .Minute )
142
+ defer cancel ()
143
+ }
144
+ return postExecutor (ctx )
145
+ }).
146
+ Finally (common .NewFieldExecutor ("step" , "Complete job" , common .NewFieldExecutor ("stepid" , []string {"--complete-job" },
147
+ common .NewInfoExecutor ("\u2B50 Run Complete job" ).
148
+ Finally (stopContainerExecutor ).
149
+ Finally (
150
+ info .interpolateOutputs ().Finally (info .closeContainer ()).Then (common .NewFieldExecutor ("stepResult" , model .StepStatusSuccess , common .NewInfoExecutor (" \u2705 Success - Complete job" ))).
151
+ OnError (common .NewFieldExecutor ("stepResult" , model .StepStatusFailure , common .NewInfoExecutor (" \u274C Failure - Complete job" ))),
152
+ )))).Finally (setJobResultExecutor ))
135
153
}
136
154
137
155
func setJobResult (ctx context.Context , info jobInfo , rc * RunContext , success bool ) {
0 commit comments