add teardown logs to execer

pull/3/head
Brad Rydzewski 4 years ago
parent b849bd35b2
commit 83c04e8f2c

@ -101,6 +101,15 @@ func Step(step *drone.Step) map[string]string {
}
}
// StepArgs returns a set of environment variables containing
// the step name and number.
func StepArgs(name string, number int64) map[string]string {
return map[string]string{
"DRONE_STEP_NAME": name,
"DRONE_STEP_NUMBER": fmt.Sprint(number),
}
}
// Build returns a set of environment variables containing
// build metadata.
func Build(build *drone.Build) map[string]string {

@ -50,7 +50,17 @@ func NewExecer(
// Exec executes the intermediate representation of the pipeline
// and returns an error if execution fails.
func (e *Execer) Exec(ctx context.Context, spec Spec, state *pipeline.State) error {
defer e.engine.Destroy(noContext, spec)
defer func() {
log := logger.FromContext(ctx)
log.Debugln("destroying the pipeline environment")
err := e.engine.Destroy(noContext, spec)
if err != nil {
log.WithError(err).
Debugln("cannot destroy the pipeline environment")
} else {
log.Debugln("successfully destroyed the pipeline environment")
}
}()
if err := e.engine.Setup(noContext, spec); err != nil {
state.FailAll(err)
@ -213,6 +223,7 @@ func (e *Execer) exec(ctx context.Context, state *pipeline.State, spec Spec, ste
// if the exit code is 78 the system will skip all
// subsequent pending steps in the pipeline.
if exited.ExitCode == 78 {
log.Debugln("received exit code 78. early exit.")
state.SkipAll()
}
return result

Loading…
Cancel
Save