예제 #1
0
파일: ciexec.go 프로젝트: rjeczalik/ciexec
// ExecBash runs script expressions in a single bash session. Execution loop
// does not stop, even if one of the commands exits with a code != 0.
// The function returns the last error encountered, if any.
func ExecBash(cmds []string, w io.Writer) error {
	s, err := bash.NewSession(w)
	if err != nil {
		return err
	}
	for _, cmd := range cmds {
		s.Start(cmd)
	}
	return s.Close()
}
예제 #2
0
파일: travis.go 프로젝트: rjeczalik/ciexec
// TODO(rjeczalik): Support matrix builds, use 'detail' to configure local execution. (#2)
// TODO(rjeczalik): Support after_success/after_failure stages. (#1)
func (travis) Exec(detail string, p []byte, w io.Writer) error {
	pro, err := travisParse(p)
	if err != nil {
		return err
	}
	cmd := travisCmd(pro)
	if cmd == nil {
		return errors.New("travis: no commands found")
	}
	s, err := bash.NewSession(w)
	if err != nil {
		return err
	}
	for _, stage := range stages {
		if cmd, ok := cmd[stage]; ok {
			for _, cmd := range cmd {
				s.Start(cmd)
			}
		}
	}
	return s.Close()
}