prow/jenkins/jenkins.go
func (c *Client) ListBuilds(jobs []BuildQueryParams) (map[string]Build, error) {
	// Get queued builds.
	jenkinsBuilds, err := c.GetEnqueuedBuilds(jobs)
	if err != nil {
		return nil, err
	}

	buildChan := make(chan map[string]Build, len(jobs))
	errChan := make(chan error, len(jobs))
	wg := &sync.WaitGroup{}
	wg.Add(len(jobs))

	// Get all running builds for all provided jobs.
	for _, job := range jobs {
		// Start a goroutine per list
		go func(job string) {
			defer wg.Done()

			builds, err := c.GetBuilds(job)
			if err != nil {
				errChan <- err
			} else {
				buildChan <- builds
			}
		}(job.JobName)
	}
	wg.Wait()

	close(buildChan)
	close(errChan)

	for err := range errChan {
		if err != nil {
			return nil, err
		}
	}

	for builds := range buildChan {
		for id, build := range builds {
			jenkinsBuilds[id] = build
		}
	}

	return jenkinsBuilds, nil
}
func (c *Client) ListBuilds(jobs []BuildQueryParams) (map[string]Build, error) {
	// Get queued builds.
	jenkinsBuilds, err := c.GetEnqueuedBuilds(jobs)
	if err != nil {
		return nil, err
	}

	buildChan := make(chan map[string]Build, len(jobs))
	errChan := make(chan error, len(jobs))
	wg := &sync.WaitGroup{}
	wg.Add(len(jobs))

	// Get all running builds for all provided jobs.
	for _, job := range jobs {
		// Start a goroutine per list
		go func(job string) {
			defer wg.Done()

			builds, err := c.GetBuilds(job)
			if err != nil {
				errChan <- err
			} else {
				buildChan <- builds
			}
		}(job.JobName)
	}
	wg.Wait()

	close(buildChan)
	close(errChan)

	for err := range errChan {
		if err != nil {
			return nil, err
		}
	}

	for builds := range buildChan {
		for id, build := range builds {
			jenkinsBuilds[id] = build
		}
	}

	return jenkinsBuilds, nil
}
func ( c * Client ) ListBuilds ( jobs [ ] BuildQueryParams ) ( map [ string ] Build , error ) { // Get queued builds. jenkinsBuilds , err := c . GetEnqueuedBuilds ( jobs ) if err != nil { return nil , err } buildChan := make ( chan map [ string ] Build , len ( jobs ) ) errChan := make ( chan error , len ( jobs ) ) wg := & sync . WaitGroup { } wg . Add ( len ( jobs ) ) // Get all running builds for all provided jobs. for _ , job := range jobs { // Start a goroutine per list go func ( job string ) { defer wg . Done ( ) builds , err := c . GetBuilds ( job ) if err != nil { errChan <- err } else { buildChan <- builds } } ( job . JobName ) } wg . Wait ( ) close ( buildChan ) close ( errChan ) for err := range errChan { if err != nil { return nil , err } } for builds := range buildChan { for id , build := range builds { jenkinsBuilds [ id ] = build } } return jenkinsBuilds , nil }
// ListBuilds returns a list of all Jenkins builds for the
// provided jobs (both scheduled and enqueued).
ListBuilds returns a list of all Jenkins builds for the provided jobs ( both scheduled and enqueued ) .