Exemplo n.º 1
0
// Artifact is a a command line interface to Artifact method of a pulse.Client.
// It downloads all artifacts captured from given project and build number
func (cli *CLI) Artifact(ctx *cli.Context) {
	var projects []string
	err := cli.init(ctx)
	if err != nil {
		cli.Err(err)
		return
	}
	if cli.p.String() == pulse.ProjectPersonal {
		projects = append(projects, pulse.ProjectPersonal)
	} else if projects, err = cli.c.Projects(); err != nil {
		cli.Err(err)
		return
	}
	var build int64
	dir, url := cli.o.String(), strings.Trim(cli.cred.URL, "/xmlrpc")
	for _, p := range projects {
		if !cli.p.MatchString(p) {
			continue
		}
		if build, err = util.NormalizeBuildOrRequestID(cli.c, p, cli.n); err != nil {
			cli.Err(err)
			return
		}
		if err = cli.c.Artifact(build, p, dir, url); err != nil {
			cli.Err(err)
			return
		}
	}
}
Exemplo n.º 2
0
// Wait TODO(rjeczalik): document
func (cli *CLI) Wait(ctx *cli.Context) {
	if err := cli.init(ctx); err != nil {
		cli.Err(err)
		return
	}
	p := cli.p.String()
	if p == "" || p == ".*" {
		cli.Err("pulsecli: a --project name is missing")
		return
	}
	id, err := util.NormalizeBuildOrRequestID(cli.c, p, cli.n)
	if err != nil {
		cli.Err(err)
		return
	}
	select {
	case <-time.After(cli.d):
		err = pulse.ErrTimeout
	case err = <-util.Wait(cli.c, time.Second, p, id):
	}
	if err != nil {
		cli.Err(err)
		return
	}
}
Exemplo n.º 3
0
// Status is a command line interface to a BuildResult methos of a pulse.Client.
// It outputs []BuildResult for every requested project in an YAML format.
func (cli *CLI) Status(ctx *cli.Context) {
	err := cli.init(ctx)
	if err != nil {
		cli.Err(err)
		return
	}
	var p []string
	if cli.p.String() == pulse.ProjectPersonal {
		p = append(p, pulse.ProjectPersonal)
	} else if p, err = cli.c.Projects(); err != nil {
		cli.Err(err)
		return
	}
	m := make(map[string][]pulse.BuildResult)
	for _, p := range p {
		if !cli.p.MatchString(p) {
			continue
		}
		id, err := util.NormalizeBuildOrRequestID(cli.c, p, cli.n)
		if err != nil {
			cli.Err(err)
			return
		}
		b, err := cli.c.BuildResult(p, id)
		if err != nil {
			cli.Err(err)
			return
		}
		m[fmt.Sprintf("%s (build %d)", p, id)] = b
	}
	y, err := yaml.Marshal(m)
	if err != nil {
		cli.Err(err)
		return
	}
	cli.Out(string(y))
}
Exemplo n.º 4
0
func (cli *CLI) healthProject(ctx *cli.Context) {
	p, err := cli.c.Projects()
	if err != nil {
		cli.Err(err)
		return
	}
	all := make(map[string]pulse.Messages)
	for _, p := range p {
		if !cli.p.MatchString(p) {
			continue
		}
		id, err := util.NormalizeBuildOrRequestID(cli.c, p, cli.n)
		if err != nil {
			cli.Err(err)
			return
		}
		m, err := cli.c.Messages(p, id)
		if err != nil {
			cli.Err(err)
			return
		}
		if m = m.FilterOut(pulse.Info); len(m) > 0 {
			all[fmt.Sprintf("%s (build %d)", p, id)] = m
		}
	}
	if len(all) == 0 {
		cli.Out()
	} else {
		y, err := yaml.Marshal(all)
		if err != nil {
			cli.Err(err)
			return
		}
		cli.Err(string(y))
	}
}