mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 08:56:29 +00:00
Gracefully handle non-zero exit code in local backend (#1002)
A non-zero exit code signifies a pipeline failure, but is not a fatal error in the agent. Since exec reports this as exec.ExitError, this has to be handled explicitly. This also fixes logs not being shown on build errors.
This commit is contained in:
parent
3f73d5bf53
commit
061596d802
1 changed files with 10 additions and 2 deletions
|
@ -94,9 +94,17 @@ func (e *local) Exec(ctx context.Context, proc *types.Step) error {
|
|||
// Wait for the pipeline step to complete and returns
|
||||
// the completion results.
|
||||
func (e *local) Wait(context.Context, *types.Step) (*types.State, error) {
|
||||
err := e.cmd.Wait()
|
||||
ExitCode := 0
|
||||
if eerr, ok := err.(*exec.ExitError); ok {
|
||||
ExitCode = eerr.ExitCode()
|
||||
// Non-zero exit code is a build failure, but not an agent error.
|
||||
err = nil
|
||||
}
|
||||
return &types.State{
|
||||
Exited: true,
|
||||
}, e.cmd.Wait()
|
||||
ExitCode: ExitCode,
|
||||
}, err
|
||||
}
|
||||
|
||||
// Tail the pipeline step logs.
|
||||
|
|
Loading…
Reference in a new issue