buildbot

package
v0.0.0-...-a0a3655 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package buildbot defines types used in Buildbot build protocol, e.g. build, step, log, etc. The types can used together with encoding/json package.

Index

Constants

This section is empty.

Variables

View Source
var ErrPropertyNotFound = errors.New("property not found")

ErrPropertyNotFound is returned by (*Build).PropertyValue if a property is no found.

Functions

This section is empty.

Types

type Build

type Build struct {
	Master      string
	Blame       []string `json:"blame"` // email addresses
	Buildername string   `json:"builderName"`
	// This needs to be reflected.  This can be either a String or a Step.
	Currentstep interface{} `json:"currentStep"`
	// We don't care about this one.
	Eta    interface{} `json:"eta"`
	Logs   []Log       `json:"logs"`
	Number int         `json:"number"`
	// This is a slice of tri-tuples of [property name, value, source].
	// property name is always a string
	// value can be a string or float
	// source is optional, but is always a string if present
	Properties  []*Property  `json:"properties"`
	Reason      string       `json:"reason"`
	Results     Result       `json:"results"`
	Slave       string       `json:"slave"`
	Sourcestamp *SourceStamp `json:"sourceStamp"`
	Steps       []Step       `json:"steps"`
	Text        []string     `json:"text"`
	Times       TimeRange    `json:"times"`
	// This one is injected by Milo.  Does not exist in a normal json query.
	TimeStamp Time `json:"timeStamp"`
	// This one is marked by Milo, denotes whether or not the build is internal.
	Internal bool `json:"internal"`
	// This one is computed by Milo for indexing purposes.  It does so by
	// checking to see if times[1] is null or not.
	Finished bool `json:"finished"`
	// OS is a string representation of the OS the build ran on.  This is
	// derived best-effort from the slave information in the master JSON.
	// This information is injected into the buildbot builds via puppet, and
	// comes as Family + Version.  Family is (windows, Darwin, Debian), while
	// Version is the version of the OS, such as (XP, 7, 10) for windows.
	OSFamily  string `json:"osFamily"`
	OSVersion string `json:"osVersion"`

	// Emulated indicates that this Buildbot build was emulated from non-Buildbot
	// e.g. from LUCI.
	Emulated bool `json:"emulated"`
	// ViewPath is an absolute path, relative to this milo host, which can be used
	// to display this Build. This Path includes a leading "/". Callers can turn
	// this into a URL by:
	//   "https://" + MiloHost + Build.ViewPath
	ViewPath string `json:"view_path"`
}

Build is a single build json on buildbot.

func (*Build) Experimental

func (b *Build) Experimental() bool

Experimental returns true if b is experimental.

func (*Build) ID

func (b *Build) ID() BuildID

ID returns b's BuildID.

func (*Build) PropertyValue

func (b *Build) PropertyValue(name string) interface{}

PropertyValue returns the named property value. If such property does not exist, returns ErrPropertyNotFound.

func (*Build) Status

func (b *Build) Status() model.Status

type BuildID

type BuildID struct {
	Master  string
	Builder string
	Number  int
}

BuildID identifies a buildbot build.

func (BuildID) String

func (id BuildID) String() string

String returns a string "{master}/{builder}/{number}".

func (BuildID) Validate

func (id BuildID) Validate() error

Validate returns an error if id is invalid.

type Builder

type Builder struct {
	Buildername   string `json:"builderName,omitempty"`
	Basedir       string `json:"basedir"`
	CachedBuilds  []int  `json:"cachedBuilds"`
	PendingBuilds int    `json:"pendingBuilds"`
	// This one is specific to the pubsub interface.  This is limited to 75,
	// so it could differ from PendingBuilds
	PendingBuildStates []*Pending `json:"pendingBuildStates"`
	Category           string     `json:"category"`
	CurrentBuilds      []int      `json:"currentBuilds"`
	Slaves             []string   `json:"slaves"`
	State              string     `json:"state"`
}

Builder is a builder struct from the master json, _not_ the builder json.

type Change

type Change struct {
	At       string  `json:"at"`
	Branch   *string `json:"branch"`
	Category string  `json:"category"`
	Comments string  `json:"comments"`
	// This could be a list of strings or list of struct { Name string } .
	Files      []interface{}   `json:"files"`
	Number     int             `json:"number"`
	Project    string          `json:"project"`
	Properties [][]interface{} `json:"properties"`
	Repository string          `json:"repository"`
	Rev        string          `json:"rev"`
	Revision   string          `json:"revision"`
	Revlink    string          `json:"revlink"`
	When       int             `json:"when"`
	Who        string          `json:"who"` // email address
}

Change describes a commit in a repository as part of a changesource of blamelist.

func (*Change) GetFiles

func (bc *Change) GetFiles() []string

type ChangeSource

type ChangeSource struct {
	Description string `json:"description"`
}

ChangeSource is a changesource (ie polling source) usually tied to a master's scheduler.

type LinkAlias

type LinkAlias struct {
	URL  string `json:"url"`
	Text string `json:"text"`
}
func (a *LinkAlias) Link() *ui.Link

type Log

type Log struct {
	Name, URL string
}

func (*Log) MarshalJSON

func (l *Log) MarshalJSON() ([]byte, error)

func (*Log) UnmarshalJSON

func (l *Log) UnmarshalJSON(data []byte) error

type Master

type Master struct {
	AcceptingBuilds struct {
		AcceptingBuilds bool `json:"accepting_builds"`
	} `json:"accepting_builds"`

	Builders map[string]*Builder `json:"builders"`

	Buildstate struct {
		AcceptingBuilds bool      `json:"accepting_builds"`
		Builders        []Builder `json:"builders"`
		Project         Project   `json:"project"`
		Timestamp       Time      `json:"timestamp"`
	} `json:"buildstate"`

	ChangeSources map[string]ChangeSource `json:"change_sources"`

	Changes map[string]Change `json:"changes"`

	Clock struct {
		Current struct {
			Local string `json:"local"`
			Utc   string `json:"utc"`
			UtcTs Time   `json:"utc_ts"`
		} `json:"current"`
		ServerStarted struct {
			Local string `json:"local"`
			Utc   string `json:"utc"`
			UtcTs Time   `json:"utc_ts"`
		} `json:"server_started"`
		ServerUptime Time `json:"server_uptime"`
	} `json:"clock"`

	Project Project `json:"project"`

	Slaves map[string]*Slave `json:"slaves"`

	Varz struct {
		AcceptingBuilds bool `json:"accepting_builds"`
		Builders        map[string]struct {
			ConnectedSlaves int    `json:"connected_slaves"`
			CurrentBuilds   int    `json:"current_builds"`
			PendingBuilds   int    `json:"pending_builds"`
			State           string `json:"state"`
			TotalSlaves     int    `json:"total_slaves"`
		} `json:"builders"`
		ServerUptime Time `json:"server_uptime"`
	} `json:"varz"`

	// This is injected by the pubsub publisher on the buildbot side.
	Name string `json:"name"`
}

Master This is json definition for https://build.chromium.org/p/<master>/json endpoints.

type Pending

type Pending struct {
	Source      SourceStamp `json:"source"`
	Reason      string      `json:"reason"`
	SubmittedAt int         `json:"submittedAt"`
	BuilderName string      `json:"builderName"`
}

type Project

type Project struct {
	BuildbotURL string `json:"buildbotURL"`
	Title       string `json:"title"`
	Titleurl    string `json:"titleURL"`
}

type Property

type Property struct {
	Name   string
	Value  interface{}
	Source string
}

func (*Property) MarshalJSON

func (p *Property) MarshalJSON() ([]byte, error)

func (*Property) UnmarshalJSON

func (p *Property) UnmarshalJSON(d []byte) error

type Result

type Result int
const (
	NoResult Result = iota - 1
	Success
	Warning
	Failure
	Skipped
	Exception
	Retry
)

func (*Result) MarshalJSON

func (r *Result) MarshalJSON() ([]byte, error)

func (Result) Status

func (r Result) Status() model.Status

Status converts r into a model.Status.

func (Result) String

func (i Result) String() string

func (*Result) UnmarshalJSON

func (r *Result) UnmarshalJSON(data []byte) error

type Slave

type Slave struct {
	// RecentBuilds is a map of builder name to a list of recent finished build
	// numbers on that builder.
	RecentBuilds  map[string][]int `json:"builders"`
	Connected     bool             `json:"connected"`
	Host          string           `json:"host"`
	Name          string           `json:"name"`
	Runningbuilds []*Build         `json:"runningBuilds"`
	Version       string           `json:"version"`
	// This is like runningbuilds, but instead of storing the full build,
	// just reference the build by builder: build num.
	RunningbuildsMap map[string][]int `json:"runningBuildsMap"`
}

Slave describes a slave on a master from a master json, and also includes the full builds of any currently running builds.

type SourceStamp

type SourceStamp struct {
	Branch     *string  `json:"branch"`
	Changes    []Change `json:"changes"`
	Haspatch   bool     `json:"hasPatch"`
	Project    string   `json:"project"`
	Repository string   `json:"repository"`
	Revision   string   `json:"revision"`
}

SourceStamp is a list of changes (commits) tagged with where the changes came from, ie. the project/repository. Also includes a "main" revision."

type Step

type Step struct {
	// We actually don't care about ETA.  This is represented as a string if
	// it's fetched from a build json, but a float if it's dug out of the
	// slave portion of a master json.  We'll just set it to interface and
	// ignore it.
	Eta          interface{}     `json:"eta"`
	Expectations [][]interface{} `json:"expectations"`
	Hidden       bool            `json:"hidden"`
	IsFinished   bool            `json:"isFinished"`
	IsStarted    bool            `json:"isStarted"`
	Logs         []Log           `json:"logs"`
	Name         string          `json:"name"`
	Results      StepResults     `json:"results"`
	Statistics   struct {
	} `json:"statistics"`
	StepNumber int               `json:"step_number"`
	Text       []string          `json:"text"`
	Times      TimeRange         `json:"times"`
	Urls       map[string]string `json:"urls"`

	// Log link aliases.  The key is a log name that is being aliases. It should,
	// generally, exist within the Logs. The value is the set of aliases attached
	// to that key.
	Aliases map[string][]*LinkAlias `json:"aliases"`
}

Step represents a single step in a buildbot build.

type StepResults

type StepResults struct {
	Result
	// contains filtered or unexported fields
}

func (*StepResults) MarshalJSON

func (r *StepResults) MarshalJSON() ([]byte, error)

func (*StepResults) UnmarshalJSON

func (r *StepResults) UnmarshalJSON(data []byte) error

type Time

type Time struct {
	time.Time
}

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

MarshalJSON marshals t to JSON at microsecond resolution.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals t from JSON at microsecond resolution.

type TimeRange

type TimeRange struct {
	Start, Finish Time
}

func MkTimeRange

func MkTimeRange(start, finish Time) TimeRange

MkTimeRange is a shorthand for:

buildbot.TimeRange{Start: start, Finish: finish}

func (*TimeRange) MarshalJSON

func (t *TimeRange) MarshalJSON() ([]byte, error)

func (*TimeRange) UnmarshalJSON

func (t *TimeRange) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL