func (j *LocalJob) buildCommand(ctx *Context) (*exec.Cmd, error) { args := args.GetArgs(j.Command) bin, err := exec.LookPath(args[0]) if err != nil { return nil, err } return &exec.Cmd{ Path: bin, Args: args, Stdout: ctx.Execution.OutputStream, Stderr: ctx.Execution.ErrorStream, Env: j.Environment, Dir: j.Dir, }, nil }
func (j *ExecJob) buildExec() (*docker.Exec, error) { exec, err := j.Client.CreateExec(docker.CreateExecOptions{ AttachStdin: false, AttachStdout: true, AttachStderr: true, Tty: j.TTY, Cmd: args.GetArgs(j.Command), Container: j.Container, User: j.User, }) if err != nil { return exec, fmt.Errorf("error creating exec: %s", err) } return exec, nil }
func (j *RunJob) buildContainer() (*docker.Container, error) { c, err := j.Client.CreateContainer(docker.CreateContainerOptions{ Config: &docker.Config{ Image: j.Image, AttachStdin: false, AttachStdout: true, AttachStderr: true, Tty: j.TTY, Cmd: args.GetArgs(j.Command), User: j.User, }, }) if err != nil { return c, fmt.Errorf("error creating exec: %s", err) } return c, nil }