本文整理汇总了Golang中github.com/wercker/wercker/core.Step.ReportPath方法的典型用法代码示例。如果您正苦于以下问题:Golang Step.ReportPath方法的具体用法?Golang Step.ReportPath怎么用?Golang Step.ReportPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/wercker/wercker/core.Step
的用法示例。
在下文中一共展示了Step.ReportPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RunStep
// RunStep runs a step and tosses error if it fails
func (p *Runner) RunStep(shared *RunnerShared, step core.Step, order int) (*StepResult, error) {
finisher := p.StartStep(shared, step, order)
sr := &StepResult{
Success: false,
Artifact: nil,
Message: "",
ExitCode: 1,
}
defer finisher.Finish(sr)
if step.ShouldSyncEnv() {
err := shared.pipeline.SyncEnvironment(shared.sessionCtx, shared.sess)
if err != nil {
// If an error occured, just log and ignore it
p.logger.WithField("Error", err).Warn("Unable to sync environment")
}
}
step.InitEnv(shared.pipeline.Env())
p.logger.Debugln("Step Environment")
for _, pair := range step.Env().Ordered() {
p.logger.Debugln(" ", pair[0], pair[1])
}
exit, err := step.Execute(shared.sessionCtx, shared.sess)
if exit != 0 {
sr.ExitCode = exit
if p.options.AttachOnError {
shared.box.RecoverInteractive(
p.options.SourcePath(),
shared.pipeline,
step,
)
}
} else if err == nil {
sr.Success = true
sr.ExitCode = 0
}
// Grab the message
var message bytes.Buffer
messageErr := step.CollectFile(shared.containerID, step.ReportPath(), "message.txt", &message)
if messageErr != nil {
if messageErr != util.ErrEmptyTarball {
return sr, messageErr
}
}
sr.Message = message.String()
// This is the error from the step.Execute above
if err != nil {
if sr.Message == "" {
sr.Message = err.Error()
}
return sr, err
}
// Grab artifacts if we want them
if p.options.ShouldArtifacts {
artifact, err := step.CollectArtifact(shared.containerID)
if err != nil {
return sr, err
}
if artifact != nil {
artificer := dockerlocal.NewArtificer(p.options, p.dockerOptions)
err = artificer.Upload(artifact)
if err != nil {
return sr, err
}
}
sr.Artifact = artifact
}
if !sr.Success {
return sr, fmt.Errorf("Step failed with exit code: %d", sr.ExitCode)
}
return sr, nil
}