// GetLastBuild retrieves the last build by job name
198715
func (client Client) GetLastBuild(jobName string) (LastBuild, error) {
	retry := retry.New(3, retry.DefaultBackoffFunc)

	var data []byte
	work := func() error {
		req, err := http.NewRequest("GET", fmt.Sprintf("%s/job/%s/lastBuild/api/json?depth=1&tree=timestamp,result,url", client.baseURL.String(), jobName), nil)
		if err != nil {
			return err
		}
		req.Header.Set("Accept", "application/json")
		req.SetBasicAuth(client.userName, client.password)

		var responseCode int
		responseCode, data, err = consumeResponse(req)
		if err != nil {
			return err
		}

		if responseCode != http.StatusOK {
			return fmt.Errorf("Status code: %d, response %s", responseCode, string(data))
		}
		return nil
	}
	if err := retry.Try(work); err != nil {
		return LastBuild{}, err
	}

	var lastBuild LastBuild
	if err := json.Unmarshal(data, &lastBuild); err != nil {
		return LastBuild{}, err
	}
	return lastBuild, nil
}
1050723
func GetBuildsWithProjectName(projectName string) []*Build {
	o := orm.NewOrm()

	var builds []*Build
	num, err := o.QueryTable("build").Filter("project_name", projectName).All(&builds)
	fmt.Printf("Returned Rows Num: %s, %s", num, err)
	return builds
}
108407
func (c *ApiController) GetBuild() {
	log.Info("Get build")

	buildId, _ := c.GetInt64(":buildId")

	build := models.GetBuildWithId(buildId)

	c.Data["json"] = build
	c.ServeJson()
}
1296807
func (b *Builder) RemoveLast() error {
	if b.stack.IsEmpty() {
		return WithStack(BuilderNeedOpenCompoundError)
	}
	tos, _ := b.stack.Tos()
	index := &b.index[b.stack.Len()-1]
	if index.IsEmpty() {
		return WithStack(BuilderNeedSubValueError)
	}
	newLength := tos + (*index)[len(*index)-1]
	lastSize := b.buf.Len() - newLength
	b.buf.Shrink(uint(lastSize))
	index.RemoveLast()
	return nil
}
577490
func (j *Jenkins) GetAllBuildIds(job string) ([]JobBuild, error) {
	jobObj, err := j.GetJob(job)
	if err != nil {
		return nil, err
	}
	return jobObj.GetAllBuildIds()
}
424891
func GetBuildWithId(buildId int64) Build {
	o := orm.NewOrm()

	build := Build{Id: buildId}
	err := o.Read(&build)
	fmt.Printf("ERR: %v\n", err)
	return build
}
218145
public function getLastBuild()
    {
        if ($this->lastBuild == null) {
            $build = new self($this->getEngine(), $this->getProject());

            return $build;
        }

        return $this->lastBuild;
    }
1352961
func GetBuildID(binary io.ReaderAt) ([]byte, error) {
	f, err := elf.NewFile(binary)
	if err != nil {
		return nil, err
	}

	findBuildID := func(notes []elfNote) ([]byte, error) {
		var buildID []byte
		for _, note := range notes {
			if note.Name == "GNU" && note.Type == noteTypeGNUBuildID {
				if buildID == nil {
					buildID = note.Desc
				} else {
					return nil, fmt.Errorf("multiple build ids found, don't know which to use")
				}
			}
		}
		return buildID, nil
	}

	for _, p := range f.Progs {
		if p.Type != elf.PT_NOTE {
			continue
		}
		notes, err := parseNotes(p.Open(), int(p.Align), f.ByteOrder)
		if err != nil {
			return nil, err
		}
		if b, err := findBuildID(notes); b != nil || err != nil {
			return b, err
		}
	}
	for _, s := range f.Sections {
		if s.Type != elf.SHT_NOTE {
			continue
		}
		notes, err := parseNotes(s.Open(), int(s.Addralign), f.ByteOrder)
		if err != nil {
			return nil, err
		}
		if b, err := findBuildID(notes); b != nil || err != nil {
			return b, err
		}
	}
	return nil, nil
}
141437
func (t *Template) GetAWSGameLiftBuildWithName(name string) (*resources.AWSGameLiftBuild, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSGameLiftBuild:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSGameLiftBuild not found", name)
}
222890
func (g *BuildGenerator) checkLastVersion(bc *buildv1.BuildConfig, lastVersion *int64) error {
	if lastVersion != nil && bc.Status.LastVersion != *lastVersion {
		klog.V(2).Infof("Aborting version triggered build for BuildConfig %s/%s because the BuildConfig LastVersion (%d) does not match the requested LastVersion (%d)", bc.Namespace, bc.Name, bc.Status.LastVersion, *lastVersion)
		return fmt.Errorf("the LastVersion(%v) on build config %s/%s does not match the build request LastVersion(%d)",
			bc.Status.LastVersion, bc.Namespace, bc.Name, *lastVersion)
	}
	return nil
}
1242985
func (m *Msg) GetLastPlugin(db *sqlx.DB) (string, string, error) {
	var res struct {
		Plugin string
		Route  string
	}
	var err error
	if m.User.ID > 0 {
		q := `SELECT route, plugin FROM messages
		      WHERE userid=$1 AND abotsent IS FALSE
		      ORDER BY createdat DESC`
		err = db.Get(&res, q, m.User.ID)
	} else {
		q := `SELECT route, plugin FROM messages
		      WHERE flexid=$1 AND flexidtype=$2 AND abotsent IS FALSE
		      ORDER BY createdat DESC`
		err = db.Get(&res, q, m.User.FlexID, m.User.FlexIDType)
	}
	if err != nil && err != sql.ErrNoRows {
		return "", "", err
	}
	return res.Plugin, res.Route, nil
}
713812
func GetLastConfigIndexFromBlock(block *cb.Block) (uint64, error) {
	md, err := GetMetadataFromBlock(block, cb.BlockMetadataIndex_LAST_CONFIG)
	if err != nil {
		return 0, err
	}
	lc := &cb.LastConfig{}
	err = proto.Unmarshal(md.Value, lc)
	if err != nil {
		return 0, errors.Wrap(err, "error unmarshaling LastConfig")
	}
	return lc.Index, nil
}
159811
func GetBuildSummary(c context.Context, id int64) (*model.BuildSummary, error) {
	// The host is set to prod because buildbot is hardcoded to talk to prod.
	uri := fmt.Sprintf("buildbucket://cr-buildbucket.appspot.com/build/%d", id)
	bs := make([]*model.BuildSummary, 0, 1)
	q := datastore.NewQuery("BuildSummary").Eq("ContextURI", uri).Limit(1)
	switch err := datastore.GetAll(c, q, &bs); {
	case err != nil:
		return nil, common.ReplaceNSEWith(err.(errors.MultiError), ErrNotFound)
	case len(bs) == 0:
		return nil, ErrNotFound
	default:
		return bs[0], nil
	}
}
594418
func (s *BuildStore) get(ctx context.Context, tx *bolt.Tx) (chronograf.BuildInfo, error) {
	var build chronograf.BuildInfo
	defaultBuild := chronograf.BuildInfo{
		Version: "pre-1.4.0.0",
		Commit:  "",
	}

	if bucket := tx.Bucket(BuildBucket); bucket == nil {
		return defaultBuild, nil
	} else if v := bucket.Get(BuildKey); v == nil {
		return defaultBuild, nil
	} else if err := internal.UnmarshalBuild(v, &build); err != nil {
		return build, err
	}
	return build, nil
}
514148
func GetBuilder(c context.Context, masterName, builderName string, limit int, cursor string) (*ui.Builder, error) {
	if err := buildstore.CanAccessMaster(c, masterName); err != nil {
		return nil, err
	}
	result := &ui.Builder{
		Name: builderName,
	}
	master, err := buildstore.GetMaster(c, masterName, false)
	if err != nil {
		return nil, err
	}
	if clock.Now(c).Sub(master.Modified) > 2*time.Minute {
		warning := fmt.Sprintf(
			"WARNING: buildbotMasterEntry data is stale (last updated %s)", master.Modified)
		logging.Warningf(c, warning)
		result.Warning = warning
	}

	builder, ok := master.Builders[builderName]
	if !ok {
		// This long block is just to return a good error message when an invalid
		// buildbot builder is specified.
		keys := make([]string, 0, len(master.Builders))
		for k := range master.Builders {
			keys = append(keys, k)
		}
		sort.Strings(keys)
		// TODO(iannucci): add error-info-helper tags to give the error page enough
		// information to render link-to-master and link-to-builder.
		builders := strings.Join(keys, "\n")
		return nil, errors.Reason(
			"Cannot find builder %q in master %q.\nAvailable builders: \n%s",
			builderName, masterName, builders,
		).Tag(grpcutil.NotFoundTag).Err()
	}

	// Extract pending builds out of the master.
	result.PendingBuilds = make([]*ui.BuildSummary, len(builder.PendingBuildStates))
	result.PendingBuildNum = builder.PendingBuilds
	logging.Debugf(c, "Number of pending builds: %d", len(builder.PendingBuildStates))
	for i, pb := range builder.PendingBuildStates {
		start := time.Unix(int64(pb.SubmittedAt), 0).UTC()
		result.PendingBuilds[i] = &ui.BuildSummary{
			PendingTime: ui.NewInterval(c, start, time.Time{}),
			Blame:       make([]*ui.Commit, len(pb.Source.Changes)),
		}
		for j, cm := range pb.Source.Changes {
			result.PendingBuilds[i].Blame[j] = &ui.Commit{
				AuthorEmail: cm.Who,
				CommitURL:   cm.Revlink,
			}
		}
	}

	baseURL := "https://build.chromium.org/p/"
	if master.Internal {
		baseURL = "https://uberchromegw.corp.google.com/i/"
	}
	result.MachinePool = summarizeSlavePool(c, baseURL+master.Name, builder.Slaves, master.Slaves)

	return result, parallel.FanOutIn(func(work chan<- func() error) {
		q := buildstore.Query{
			Master:  masterName,
			Builder: builderName,

			NoAnnotationFetch: true,
		}
		work <- func() error {
			q := q
			q.Limit = limit
			q.Cursor = cursor
			q.Finished = buildstore.Yes
			res, err := buildstore.GetBuilds(c, q)
			if err != nil {
				return err
			}
			result.NextCursor = res.NextCursor
			result.PrevCursor = res.PrevCursor
			result.FinishedBuilds = make([]*ui.BuildSummary, len(res.Builds))
			for i, b := range res.Builds {
				result.FinishedBuilds[i] = renderBuild(c, b, false).BuildSummary()
			}
			return err
		}
		work <- func() error {
			q := q
			q.Finished = buildstore.No
			res, err := buildstore.GetBuilds(c, q)
			if err != nil {
				return err
			}
			result.CurrentBuilds = make([]*ui.BuildSummary, len(res.Builds))
			for i, b := range res.Builds {
				// currentBuilds is presented in reversed order, so flip it
				result.CurrentBuilds[len(res.Builds)-i-1] = renderBuild(c, b, false).BuildSummary()
			}
			return err
		}
	})
}
1232991
func (f *FakeDocker) GetOnBuild(imageName string) ([]string, error) {
	f.OnBuildImage = imageName
	return f.OnBuildResult, f.OnBuildError
}
950163
func GetBuildPodName(build *buildapi.Build) string {
	return apihelpers.GetPodName(build.Name, buildPodSuffix)
}