本文整理匯總了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
}