File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,13 @@ func (e *docker) Run() error {
88
88
return err
89
89
}
90
90
91
+ defer func () {
92
+ if e .autoRemove {
93
+ err := cli .ContainerRemove (ctx , resp .ID , types.ContainerRemoveOptions {})
94
+ util .LogErr ("docker executor: remove container" , err )
95
+ }
96
+ }()
97
+
91
98
statusCh , errCh := cli .ContainerWait (
92
99
ctx , resp .ID , container .WaitConditionNotRunning ,
93
100
)
@@ -96,7 +103,10 @@ func (e *docker) Run() error {
96
103
if err != nil {
97
104
return err
98
105
}
99
- case <- statusCh :
106
+ case status := <- statusCh :
107
+ if status .StatusCode != 0 {
108
+ return fmt .Errorf ("exit status %v" , status .StatusCode )
109
+ }
100
110
}
101
111
102
112
out , err := cli .ContainerLogs (
@@ -109,11 +119,6 @@ func (e *docker) Run() error {
109
119
_ , err = stdcopy .StdCopy (e .stdout , e .stdout , out )
110
120
util .LogErr ("docker executor: stdcopy" , err )
111
121
112
- if e .autoRemove {
113
- err := cli .ContainerRemove (ctx , resp .ID , types.ContainerRemoveOptions {})
114
- util .LogErr ("docker executor: remove container" , err )
115
- }
116
-
117
122
return nil
118
123
}
119
124
You can’t perform that action at this time.
0 commit comments