circleci

package module
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 14 Imported by: 2

README

go-circleci

GoDoc Circle CI Go Report Card coverage

Go library for interacting with CircleCI's API. Supports all current API endpoints allowing you do do things like:

  • Query for recent builds
  • Get build details
  • Retry builds
  • Manipulate checkout keys, environment variables, and other settings for a project

The CircleCI HTTP API response schemas are not well documented so please file an issue if you run into something that doesn't match up.

Example usage:

package main

import (
        "fmt"

        "github.com/jszwedko/go-circleci"
)

func main() {
        client := &circleci.Client{Token: "YOUR TOKEN"} // Token not required to query info for public projects

        builds, _ := client.ListRecentBuildsForProject("jszwedko", "circleci-cli", "master", "", -1, 0)

        for _, build := range builds {
                fmt.Printf("%d: %s\n", build.BuildNum, build.Status)
        }
}

For the CLI that uses this library (or to see more example usages), please see circleci-cli.

See GoDoc for API usage.

Feature requests and issues welcome!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	HTTPStatusCode int
	Message        string
}

APIError represents an error from CircleCI

func (*APIError) Error

func (e *APIError) Error() string

type APIVersion added in v0.5.0

type APIVersion uint8

APIVersion denotes the version of the API to be used by the client.

const (
	APIVersionNone APIVersion = iota
	APIVersion11
	APIVersion2
)

func (APIVersion) String added in v0.5.0

func (v APIVersion) String() string

String returns a string form of the version.

type AWSConfig

type AWSConfig struct {
	AWSKeypair *AWSKeypair `json:"keypair"`
}

AWSConfig represents AWS configuration for a project

type AWSKeypair

type AWSKeypair struct {
	AccessKeyID     string `json:"access_key_id"`
	SecretAccessKey string `json:"secret_access_key_id"`
}

AWSKeypair represents the AWS access/secret key for a project SecretAccessKey will be a masked value

type Action

type Action struct {
	Background         bool       `json:"background"`
	BashCommand        *string    `json:"bash_command"`
	Canceled           *bool      `json:"canceled"`
	Continue           *string    `json:"continue"`
	EndTime            *time.Time `json:"end_time"`
	ExitCode           *int       `json:"exit_code"`
	Failed             *bool      `json:"failed"`
	HasOutput          bool       `json:"has_output"`
	Index              int        `json:"index"`
	InfrastructureFail *bool      `json:"infrastructure_fail"`
	Messages           []string   `json:"messages"`
	Name               string     `json:"name"`
	OutputURL          string     `json:"output_url"`
	Parallel           bool       `json:"parallel"`
	RunTimeMillis      int        `json:"run_time_millis"`
	StartTime          *time.Time `json:"start_time"`
	Status             string     `json:"status"`
	Step               int        `json:"step"`
	Timedout           *bool      `json:"timedout"`
	Truncated          bool       `json:"truncated"`
	Type               string     `json:"type"`
}

Action represents an individual action within a build step

type Actor added in v0.6.0

type Actor struct {
	Login     string `json:"login"`
	AvatarURL string `json:"avatar_url"`
}

type Artifact

type Artifact struct {
	NodeIndex  int    `json:"node_index"`
	Path       string `json:"path"`
	PrettyPath string `json:"pretty_path"`
	URL        string `json:"url"`
}

Artifact represents a build artifact

type Branch

type Branch struct {
	LastSuccess   *BuildSummary   `json:"last_success"`
	PusherLogins  []string        `json:"pusher_logins"`
	RecentBuilds  []*BuildSummary `json:"recent_builds"`
	RunningBuilds []*BuildSummary `json:"running_builds"`
}

Branch represents a repository branch

type Build

type Build struct {
	AllCommitDetails        []*CommitDetails  `json:"all_commit_details"`
	AuthorDate              *time.Time        `json:"author_date"`
	AuthorEmail             string            `json:"author_email"`
	AuthorName              string            `json:"author_name"`
	Body                    string            `json:"body"`
	Branch                  string            `json:"branch"`
	BuildNum                int               `json:"build_num"`
	BuildParameters         map[string]string `json:"build_parameters"`
	BuildTimeMillis         *int              `json:"build_time_millis"`
	BuildURL                string            `json:"build_url"`
	Canceled                bool              `json:"canceled"`
	CircleYML               *CircleYML        `json:"circle_yml"`
	CommitterDate           *time.Time        `json:"committer_date"`
	CommitterEmail          string            `json:"committer_email"`
	CommitterName           string            `json:"committer_name"`
	Compare                 *string           `json:"compare"`
	DontBuild               *string           `json:"dont_build"`
	Failed                  *bool             `json:"failed"`
	FeatureFlags            map[string]string `json:"feature_flags"`
	InfrastructureFail      bool              `json:"infrastructure_fail"`
	IsFirstGreenBuild       bool              `json:"is_first_green_build"`
	JobName                 *string           `json:"job_name"`
	Lifecycle               string            `json:"lifecycle"`
	Messages                []*Message        `json:"messages"`
	Node                    []*Node           `json:"node"`
	OSS                     bool              `json:"oss"`
	Outcome                 string            `json:"outcome"`
	Parallel                int               `json:"parallel"`
	Picard                  *Picard           `json:"picard"`
	Platform                string            `json:"platform"`
	Previous                *BuildStatus      `json:"previous"`
	PreviousSuccessfulBuild *BuildStatus      `json:"previous_successful_build"`
	PullRequests            []*PullRequest    `json:"pull_requests"`
	QueuedAt                string            `json:"queued_at"`
	Reponame                string            `json:"reponame"`
	Retries                 []int             `json:"retries"`
	RetryOf                 *int              `json:"retry_of"`
	SSHEnabled              *bool             `json:"ssh_enabled"`
	SSHUsers                []*SSHUser        `json:"ssh_users"`
	StartTime               *time.Time        `json:"start_time"`
	Status                  string            `json:"status"`
	Steps                   []*Step           `json:"steps"`
	StopTime                *time.Time        `json:"stop_time"`
	Subject                 string            `json:"subject"`
	Timedout                bool              `json:"timedout"`
	UsageQueuedAt           string            `json:"usage_queued_at"`
	User                    *BuildUser        `json:"user"`
	Username                string            `json:"username"`
	VcsRevision             string            `json:"vcs_revision"`
	VcsTag                  string            `json:"vcs_tag"`
	VCSURL                  string            `json:"vcs_url"`
	Workflows               *Workflow         `json:"workflows"`
	Why                     string            `json:"why"`
}

Build represents the details of a build

type BuildAgent added in v0.3.0

type BuildAgent struct {
	Image      *string               `json:"image"`
	Properties *BuildAgentProperties `json:"properties"`
}

BuildAgent represents an agent's information

type BuildAgentProperties added in v0.3.0

type BuildAgentProperties struct {
	BuildAgent string `json:"image"`
	Executor   string `json:"executor"`
}

BuildAgentProperties represents agent properties

type BuildByProjectResponse added in v0.4.0

type BuildByProjectResponse struct {
	Status int    `json:"status"`
	Body   string `json:"body"`
}

BuildByProjectResponse is the shape of the response body from the trigger build by project endpoint

type BuildStatus

type BuildStatus struct {
	BuildTimeMillis int    `json:"build_time_millis"`
	Status          string `json:"status"`
	BuildNum        int    `json:"build_num"`
}

BuildStatus represents status information about the build Used when a short summary of previous builds is included

type BuildSummary

type BuildSummary struct {
	AddedAt     time.Time `json:"added_at"`
	BuildNum    int       `json:"build_num"`
	Outcome     string    `json:"outcome"`
	PushedAt    time.Time `json:"pushed_at"`
	Status      string    `json:"status"`
	VCSRevision string    `json:"vcs_revision"`
}

BuildSummary represents the subset of build information returned with a Project

type BuildUser

type BuildUser struct {
	Email  *string `json:"email"`
	IsUser bool    `json:"is_user"`
	Login  string  `json:"login"`
	Name   *string `json:"name"`
}

BuildUser represents the user that triggered the build

type CancelWorkflow added in v0.7.0

type CancelWorkflow struct {
	Message string `json:"message,omitempty"`
}

type CheckoutKey

type CheckoutKey struct {
	PublicKey   string    `json:"public_key"`
	Type        string    `json:"type"` // github-user-key or deploy-key
	Fingerprint string    `json:"fingerprint"`
	Login       *string   `json:"login"` // github username if this is a user key
	Preferred   bool      `json:"preferred"`
	Time        time.Time `json:"time"` // time key was created
}

CheckoutKey represents an SSH checkout key for a project

type CircleYML

type CircleYML struct {
	String string `json:"string"`
}

CircleYML represents the serialized CircleCI YML file for a given build

type Client

type Client struct {
	BaseURL    *url.URL     // CircleCI API endpoint (defaults to DefaultEndpoint)
	Token      string       // CircleCI API token (needed for private repositories and mutative actions)
	HTTPClient *http.Client // HTTPClient to use for connecting to CircleCI (defaults to http.DefaultClient)

	Debug   bool   // debug logging enabled
	Logger  Logger // logger to send debug messages on (if enabled), defaults to logging to stderr with the standard flags
	Version APIVersion
}

Client is a CircleCI client Its zero value is a usable client for examining public CircleCI repositories

func NewClient added in v0.5.0

func NewClient(token string, version APIVersion) (*Client, error)

NewClient returns a new CircleCI client by settings the baseURL depending on the API version passed.

func (*Client) AddEnvVar

func (c *Client) AddEnvVar(vcsType VcsType, account, repo, name, value string) (*EnvVar, error)

AddEnvVar adds a new environment variable to the specified project Returns the added env var (the value will be masked)

func (*Client) AddEnvVarWithContext added in v0.4.0

func (c *Client) AddEnvVarWithContext(ctx context.Context, vcsType VcsType, account, repo, name, value string) (*EnvVar, error)

AddEnvVarWithContext is the same as AddEnvVar with the addition of the context parameter that would be used to request cancellation.

func (*Client) AddHerokuKey

func (c *Client) AddHerokuKey(key string) error

AddHerokuKey associates a Heroku key with the user's API token to allow CircleCI to deploy to Heroku on your behalf

The API token being used must be a user API token

NOTE: It doesn't look like there is currently a way to dissaccociate your Heroku key, so use with care

func (*Client) AddHerokuKeyWithContext added in v0.4.0

func (c *Client) AddHerokuKeyWithContext(ctx context.Context, key string) error

AddHerokuKeyWithContext is the same as AddHerokuKey with the addition of the context parameter that would be used to request cancellation.

func (*Client) AddSSHKey

func (c *Client) AddSSHKey(vcsType VcsType, account, repo, hostname, privateKey string) error

AddSSHKey adds a new SSH key to the project

func (*Client) AddSSHKeyWithContext added in v0.4.0

func (c *Client) AddSSHKeyWithContext(ctx context.Context, vcsType VcsType, account, repo, hostname, privateKey string) error

AddSSHKeyWithContext is the same as AddSSHKey with the addition of the context parameter that would be used to request cancellation.

func (*Client) AddSSHUser

func (c *Client) AddSSHUser(vcsType VcsType, account, repo string, buildNum int) (*Build, error)

AddSSHUser adds the user associated with the API token to the list of valid SSH users for a build.

The API token being used must be a user API token

func (*Client) AddSSHUserWithContext added in v0.4.0

func (c *Client) AddSSHUserWithContext(ctx context.Context, vcsType VcsType, account, repo string, buildNum int) (*Build, error)

AddSSHUserWithContext is the same as AddSSHUser with the addition of the context parameter that would be used to request cancellation.

func (*Client) Build

func (c *Client) Build(vcsType VcsType, account, repo, branch string) (*Build, error)

Build triggers a new build for the given project for the given project on the given branch. Returns the new build information

func (*Client) BuildByProject added in v0.4.0

func (c *Client) BuildByProject(vcsType VcsType, account string, repo string, opts map[string]interface{}) error

BuildByProject triggers a build by project (this is the only way to trigger a build for project using Circle 2.1) you can set revision and/or tag/branch this is useful if you need to trigger a build from a PR froma fork, in which you need to set the revision and the branch in this format `pull/PR_NUMBER` ie.:

 map[string]interface{}{
		"revision": "8afbae7ec63b2b0f2786740d03161dbb08ba55f5",
		"branch"  : "pull/1234",
	})

NOTE: this endpoint is only available in the CircleCI API v1.1. in order to call it, you must instantiate the Client object with the following value for BaseURL: &url.URL{Host: "circleci.com", Scheme: "https", Path: "/api/v1.1/"}

func (*Client) BuildByProjectBranch added in v0.4.0

func (c *Client) BuildByProjectBranch(vcsType VcsType, account, repo, branch string) error

BuildByProjectBranch triggers a build by project (this is the only way to trigger a build for project using Circle 2.1) by branch

NOTE: this endpoint is only available in the CircleCI API v1.1. in order to call it, you must instantiate the Client object with the following value for BaseURL: &url.URL{Host: "circleci.com", Scheme: "https", Path: "/api/v1.1/"}

func (*Client) BuildByProjectBranchWithContext added in v0.4.0

func (c *Client) BuildByProjectBranchWithContext(ctx context.Context, vcsType VcsType, account, repo, branch string) error

BuildByProjectBranchWithContext is the same as BuildByProjectBranch with the addition of the context parameter that would be used to request cancellation.

func (*Client) BuildByProjectRevision added in v0.4.0

func (c *Client) BuildByProjectRevision(vcsType VcsType, account string, repo string, revision string) error

BuildByProjectRevision triggers a build by project (this is the only way to trigger a build for project using Circle 2.1) by revision

NOTE: this endpoint is only available in the CircleCI API v1.1. in order to call it, you must instantiate the Client object with the following value for BaseURL: &url.URL{Host: "circleci.com", Scheme: "https", Path: "/api/v1.1/"}

func (*Client) BuildByProjectRevisionWithContext added in v0.4.0

func (c *Client) BuildByProjectRevisionWithContext(ctx context.Context, vcsType VcsType, account, repo, revision string) error

BuildByProjectRevisionWithContext is the same as BuildByProjectRevision with the addition of the context parameter that would be used to request cancellation.

func (*Client) BuildByProjectTag added in v0.4.0

func (c *Client) BuildByProjectTag(vcsType VcsType, account, repo, tag string) error

BuildByProjectTag triggers a build by project (this is the only way to trigger a build for project using Circle 2.1) using a tag reference

NOTE: this endpoint is only available in the CircleCI API v1.1. in order to call it, you must instantiate the Client object with the following value for BaseURL: &url.URL{Host: "circleci.com", Scheme: "https", Path: "/api/v1.1/"}

func (*Client) BuildByProjectTagWithContext added in v0.4.0

func (c *Client) BuildByProjectTagWithContext(ctx context.Context, vcsType VcsType, account, repo, tag string) error

BuildByProjectTagWithContext is the same as BuildByProjectTag with the addition of the context parameter that would be used to request cancellation.

func (*Client) BuildByProjectWithContext added in v0.4.0

func (c *Client) BuildByProjectWithContext(ctx context.Context, vcsType VcsType, account, repo string, opts map[string]interface{}) error

BuildByProjectWithContext is the same as BuildByProject with the addition of the context parameter that would be used to request cancellation.

func (*Client) BuildOpts added in v0.3.0

func (c *Client) BuildOpts(vcsType VcsType, account, repo, branch string, opts map[string]interface{}) (*Build, error)

BuildOpts triggeres a new build for the givent project on the given branch, Marshaling the struct into json and passing in the post body. Returns the new build information

func (*Client) BuildOptsWithContext added in v0.4.0

func (c *Client) BuildOptsWithContext(ctx context.Context, vcsType VcsType, account, repo, branch string, opts map[string]interface{}) (*Build, error)

BuildOptsWithContext is the same as BuildOpts with the addition of the context parameter that would be used to request cancellation.

func (*Client) BuildWithContext added in v0.4.0

func (c *Client) BuildWithContext(ctx context.Context, vcsType VcsType, account, repo, branch string) (*Build, error)

BuildWithContext is the same as Build with the addition of the context parameter that would be used to request cancellation.

func (*Client) CancelBuild

func (c *Client) CancelBuild(vcsType VcsType, account, repo string, buildNum int) (*Build, error)

CancelBuild triggers a cancel of the specified build Returns the new build information

func (*Client) CancelBuildWithContext added in v0.4.0

func (c *Client) CancelBuildWithContext(ctx context.Context, vcsType VcsType, account, repo string, buildNum int) (*Build, error)

CancelBuildWithContext is the same as CancelBuild with the addition of the context parameter that would be used to request cancellation.

func (*Client) CancelWorkflow added in v0.7.0

func (c *Client) CancelWorkflow(workflowID string) (*CancelWorkflow, error)

CancelWorkflow triggers a cancel of the specified workflow using CirclerCI apiV2 Returns a status message

func (*Client) CancelWorkflowWithContext added in v0.7.0

func (c *Client) CancelWorkflowWithContext(ctx context.Context, workflowID string) (*CancelWorkflow, error)

CancelWorkflowWithContext is the same as CancelWorkflow with the addition of the context parameter that would be used to request cancellation.

func (*Client) ClearCache

func (c *Client) ClearCache(vcsType VcsType, account, repo string) (string, error)

ClearCache clears the cache of the specified project Returns the status returned by CircleCI

func (*Client) ClearCacheWithContext added in v0.4.0

func (c *Client) ClearCacheWithContext(ctx context.Context, vcsType VcsType, account, repo string) (string, error)

ClearCacheWithContext is the same as ClearCache with the addition of the context parameter that would be used to request cancellation.

func (*Client) CreateCheckoutKey

func (c *Client) CreateCheckoutKey(vcsType VcsType, account, repo, keyType string) (*CheckoutKey, error)

CreateCheckoutKey creates a new checkout key for a project Valid key types are currently deploy-key and github-user-key

The github-user-key type requires that the API token being used be a user API token

func (*Client) CreateCheckoutKeyWithContext added in v0.4.0

func (c *Client) CreateCheckoutKeyWithContext(ctx context.Context, vcsType VcsType, account, repo, keyType string) (*CheckoutKey, error)

CreateCheckoutKeyWithContext is the same as CreateCheckoutKey with the addition of the context parameter that would be used to request cancellation.

func (*Client) DeleteCheckoutKey

func (c *Client) DeleteCheckoutKey(vcsType VcsType, account, repo, fingerprint string) error

DeleteCheckoutKey fetches the checkout key for the given project by fingerprint

func (*Client) DeleteCheckoutKeyWithContext added in v0.4.0

func (c *Client) DeleteCheckoutKeyWithContext(ctx context.Context, vcsType VcsType, account, repo, fingerprint string) error

GetCheckoutKeyWithContext is the same as GetCheckoutKey with the addition of the context parameter that would be used to request cancellation.

func (*Client) DeleteEnvVar

func (c *Client) DeleteEnvVar(vcsType VcsType, account, repo, name string) error

DeleteEnvVar deletes the specified environment variable from the project

func (*Client) DeleteEnvVarWithContext added in v0.4.0

func (c *Client) DeleteEnvVarWithContext(ctx context.Context, vcsType VcsType, account, repo, name string) error

DeleteEnvVarWithContext is the same as DeleteEnvVar with the addition of the context parameter that would be used to request cancellation.

func (*Client) DisableProject

func (c *Client) DisableProject(vcsType VcsType, account, repo string) error

DisableProject disables a project

func (*Client) DisableProjectWithContext added in v0.4.0

func (c *Client) DisableProjectWithContext(ctx context.Context, vcsType VcsType, account, repo string) error

DisableProjectWithContext is the same as DisableProject with the addition of the context parameter that would be used to request cancellation.

func (*Client) EnableProject

func (c *Client) EnableProject(vcsType VcsType, account, repo string) error

EnableProject enables a project - generates a deploy SSH key used to checkout the Github repo. The Github user tied to the Circle API Token must have "admin" access to the repo.

func (*Client) EnableProjectWithContext added in v0.4.0

func (c *Client) EnableProjectWithContext(ctx context.Context, vcsType VcsType, account, repo string) error

EnableProjectWithContext is the same as EnableProject with the addition of the context parameter that would be used to request cancellation.

func (*Client) FollowProject

func (c *Client) FollowProject(vcsType VcsType, account, repo string) (*Project, error)

FollowProject follows a project

func (*Client) FollowProjectWithContext added in v0.4.0

func (c *Client) FollowProjectWithContext(ctx context.Context, vcsType VcsType, account, repo string) (*Project, error)

FollowProjectWithContext is the same as FollowProject with the addition of the context parameter that would be used to request cancellation.

func (*Client) GetActionOutputs

func (c *Client) GetActionOutputs(a *Action) ([]*Output, error)

GetActionOutputs fetches the output for the given action If the action has no output, returns nil

func (*Client) GetActionOutputsWithContext added in v0.4.0

func (c *Client) GetActionOutputsWithContext(ctx context.Context, a *Action) ([]*Output, error)

GetActionOutputWithContext is the same as GetActionOutput with the addition of the context parameter that would be used to request cancellation.

func (*Client) GetBuild

func (c *Client) GetBuild(vcsType VcsType, account, repo string, buildNum int) (*Build, error)

GetBuild fetches a given build by number

func (*Client) GetBuildWithContext added in v0.4.0

func (c *Client) GetBuildWithContext(ctx context.Context, vcsType VcsType, account, repo string, buildNum int) (*Build, error)

GetBuildWithContext is the same as GetBuild with the addition of the context parameter that would be used to request cancellation.

func (*Client) GetCheckoutKey

func (c *Client) GetCheckoutKey(vcsType VcsType, account, repo, fingerprint string) (*CheckoutKey, error)

GetCheckoutKey fetches the checkout key for the given project by fingerprint

func (*Client) GetCheckoutKeyWithContext added in v0.4.0

func (c *Client) GetCheckoutKeyWithContext(ctx context.Context, vcsType VcsType, account, repo, fingerprint string) (*CheckoutKey, error)

GetCheckoutKeyWithContext is the same as GetCheckoutKey with the addition of the context parameter that would be used to request cancellation.

func (*Client) GetPipelineByBranch added in v0.6.0

func (c *Client) GetPipelineByBranch(vcsType VcsType, account, repo, branch, pageToken string) (*Pipelines, error)

GetPipelineByBranch calls GetPipelineByBranchWithContext with context.Background.

func (*Client) GetPipelineByBranchWithContext added in v0.6.0

func (c *Client) GetPipelineByBranchWithContext(ctx context.Context, vcsType VcsType, account, repo, branch, pageToken string) (*Pipelines, error)

GetPipelineByBranchWithContext gets a pipeline for the given project for the given branch. https://circleci.com/docs/api/v2/#operation/listPipelinesForProject Note that this is only available as a v2 API.

func (*Client) GetPipelineWorkflow added in v0.5.0

func (c *Client) GetPipelineWorkflow(pipelineID, pageToken string) (*WorkflowList, error)

GetPipelineWorkflow calls GetPipelineWorkflowWithContext with context.Background.

func (*Client) GetPipelineWorkflowWithContext added in v0.5.0

func (c *Client) GetPipelineWorkflowWithContext(ctx context.Context, pipelineID, pageToken string) (*WorkflowList, error)

GetPipelineWorkflowWithContext returns a list of paginated workflows by pipeline ID https://circleci.com/docs/api/v2/?shell#get-a-pipeline-39-s-workflows Note that this is only available as a v2 API.

func (*Client) GetProject

func (c *Client) GetProject(account, repo string) (*Project, error)

GetProject retrieves a specific project Returns nil of the project is not in the list of watched projects

func (*Client) GetProjectWithContext added in v0.4.0

func (c *Client) GetProjectWithContext(ctx context.Context, account, repo string) (*Project, error)

GetProjectWithContext is the same as GetProject with the addition of the context parameter that would be used to request cancellation.

func (*Client) ListBuildArtifacts

func (c *Client) ListBuildArtifacts(vcsType VcsType, account, repo string, buildNum int) ([]*Artifact, error)

ListBuildArtifacts fetches the build artifacts for the given build

func (*Client) ListBuildArtifactsWithContext added in v0.4.0

func (c *Client) ListBuildArtifactsWithContext(ctx context.Context, vcsType VcsType, account, repo string, buildNum int) ([]*Artifact, error)

ListBuildArtifactsWithContext is the same as ListBuildArtifacts with the addition of the context parameter that would be used to request cancellation.

func (*Client) ListCheckoutKeys

func (c *Client) ListCheckoutKeys(vcsType VcsType, account, repo string) ([]*CheckoutKey, error)

ListCheckoutKeys fetches the checkout keys associated with the given project

func (*Client) ListCheckoutKeysWithContext added in v0.4.0

func (c *Client) ListCheckoutKeysWithContext(ctx context.Context, vcsType VcsType, account, repo string) ([]*CheckoutKey, error)

ListCheckoutKeysWithContext is the same as ListCheckoutKeys with the addition of the context parameter that would be used to request cancellation.

func (*Client) ListEnvVars

func (c *Client) ListEnvVars(vcsType VcsType, account, repo string) ([]EnvVar, error)

ListEnvVars list environment variable to the specified project Returns the env vars (the value will be masked)

func (*Client) ListEnvVarsWithContext added in v0.4.0

func (c *Client) ListEnvVarsWithContext(ctx context.Context, vcsType VcsType, account, repo string) ([]EnvVar, error)

ListEnvVarsWithContext is the same as ListEnvVars with the addition of the context parameter that would be used to request cancellation.

func (*Client) ListProjects

func (c *Client) ListProjects() ([]*Project, error)

ListProjectsWithContext returns the list of projects the user is watching

func (*Client) ListProjectsWithContext added in v0.4.0

func (c *Client) ListProjectsWithContext(ctx context.Context) ([]*Project, error)

ListProjectsWithContext is the same as ListProjects with the addition of the context parameter that would be used to request cancellation.

func (*Client) ListRecentBuilds

func (c *Client) ListRecentBuilds(limit, offset int) ([]*Build, error)

ListRecentBuilds fetches the list of recent builds for all repositories the user is watching If limit is -1, fetches all builds

func (*Client) ListRecentBuildsForProject

func (c *Client) ListRecentBuildsForProject(vcsType VcsType, account, repo, branch, status string, limit, offset int) ([]*Build, error)

ListRecentBuildsForProject fetches the list of recent builds for the given repository The status and branch parameters are used to further filter results if non-empty If limit is -1, fetches all builds

func (*Client) ListRecentBuildsForProjectWithContext added in v0.4.0

func (c *Client) ListRecentBuildsForProjectWithContext(ctx context.Context, vcsType VcsType, account, repo, branch, status string, limit, offset int) ([]*Build, error)

ListRecentBuildsForProjectWithContext is the same as ListRecentBuildsForProject with the addition of the context parameter that would be used to request cancellation.

func (*Client) ListRecentBuildsWithContext added in v0.4.0

func (c *Client) ListRecentBuildsWithContext(ctx context.Context, limit, offset int) ([]*Build, error)

ListRecentBuildsWithContext is the same as ListRecentBuilds with the addition of the context parameter that would be used to request cancellation.

func (*Client) ListTestMetadata

func (c *Client) ListTestMetadata(vcsType VcsType, account, repo string, buildNum int) ([]*TestMetadata, error)

ListTestMetadata fetches the build metadata for the given build

func (*Client) ListTestMetadataWithContext added in v0.4.0

func (c *Client) ListTestMetadataWithContext(ctx context.Context, vcsType VcsType, account, repo string, buildNum int) ([]*TestMetadata, error)

ListTestMetadataWithContext is the same as ListTestMetadata with the addition of the context parameter that would be used to request cancellation.

func (*Client) Me

func (c *Client) Me() (*User, error)

func (*Client) MeWithContext added in v0.4.0

func (c *Client) MeWithContext(ctx context.Context) (*User, error)

Me returns information about the current user

func (*Client) ParameterizedBuild

func (c *Client) ParameterizedBuild(vcsType VcsType, account, repo, branch string, buildParameters map[string]string) (*Build, error)

ParameterizedBuild triggers a new parameterized build for the given project on the given branch, Marshaling the struct into json and passing in the post body. Returns the new build information

func (*Client) ParameterizedBuildWithContext added in v0.4.0

func (c *Client) ParameterizedBuildWithContext(ctx context.Context, vcsType VcsType, account, repo, branch string, buildParameters map[string]string) (*Build, error)

ParametrizedBuildWithContext is the same as ParametrizedBuild with the addition of the context parameter that would be used to request cancellation.

func (*Client) RetryBuild

func (c *Client) RetryBuild(vcsType VcsType, account, repo string, buildNum int) (*Build, error)

RetryBuild triggers a retry of the specified build Returns the new build information

func (*Client) RetryBuildWithContext added in v0.4.0

func (c *Client) RetryBuildWithContext(ctx context.Context, vcsType VcsType, account, repo string, buildNum int) (*Build, error)

RetryBuildWithContext is the same as RetryBuild with the addition of the context parameter that would be used to request cancellation.

func (*Client) TriggerPipeline added in v0.5.0

func (c *Client) TriggerPipeline(vcsType VcsType, account, repo, branch, tag string, params map[string]interface{}) (*Pipeline, error)

TriggerPipeline calls TriggerPipelineWithContext with context.Background.

func (*Client) TriggerPipelineWithContext added in v0.5.0

func (c *Client) TriggerPipelineWithContext(ctx context.Context, vcsType VcsType, account, repo, branch, tag string, params map[string]interface{}) (*Pipeline, error)

TriggerPipeline triggers a new pipeline for the given project for the given branch or tag. Note that branch and tag are mutually exclusive and if both are sent circleci will return an error https://circleci.com/docs/api/v2/?shell#trigger-a-new-pipeline Note that this is only available as a v2 API.

func (*Client) UnfollowProject added in v0.4.0

func (c *Client) UnfollowProject(vcsType VcsType, account, repo string) (*Project, error)

UnfollowProject unfollows a project

func (*Client) UnfollowProjectWithContext added in v0.4.0

func (c *Client) UnfollowProjectWithContext(ctx context.Context, vcsType VcsType, account, repo string) (*Project, error)

UnfollowProjectWithContext is the same as UnfollowProject with the addition of the context parameter that would be used to request cancellation.

type CommitDetails

type CommitDetails struct {
	AuthorDate     *time.Time `json:"author_date"`
	AuthorEmail    string     `json:"author_email"`
	AuthorLogin    string     `json:"author_login"`
	AuthorName     string     `json:"author_name"`
	Body           string     `json:"body"`
	Branch         string     `json:"branch"`
	Commit         string     `json:"commit"`
	CommitURL      string     `json:"commit_url"`
	CommitterDate  *time.Time `json:"committer_date"`
	CommitterEmail string     `json:"committer_email"`
	CommitterLogin string     `json:"committer_login"`
	CommitterName  string     `json:"committer_name"`
	Subject        string     `json:"subject"`
}

CommitDetails represents information about a commit returned with other structs

type EnvVar

type EnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

EnvVar represents an environment variable

type FeatureFlags added in v0.2.0

type FeatureFlags struct {
	TrustyBeta             bool    `json:"trusty-beta"`
	OSX                    bool    `json:"osx"`
	SetGithubStatus        bool    `json:"set-github-status"`
	BuildPRsOnly           bool    `json:"build-prs-only"`
	ForksReceiveSecretVars bool    `json:"forks-receive-secret-env-vars"`
	Fleet                  *string `json:"fleet"`
	BuildForkPRs           bool    `json:"build-fork-prs"`
	AutocancelBuilds       bool    `json:"autocancel-builds"`
	OSS                    bool    `json:"oss"`
	MemoryLimit            *string `json:"memory-limit"`
	// contains filtered or unexported fields
}

func (*FeatureFlags) Raw added in v0.2.0

func (f *FeatureFlags) Raw() map[string]interface{}

Raw returns the underlying map[string]interface{} representing the feature flags This is useful to access flags that have been added to the API, but not yet added to this library

func (*FeatureFlags) UnmarshalJSON added in v0.2.0

func (f *FeatureFlags) UnmarshalJSON(b []byte) error

type InvalidVersionError added in v0.5.0

type InvalidVersionError struct {
	// contains filtered or unexported fields
}

func (*InvalidVersionError) Error added in v0.5.0

func (e *InvalidVersionError) Error() string

type Items added in v0.6.0

type Items struct {
	ID          string  `json:"id"`
	ProjectSlug string  `json:"project_slug"`
	UpdatedAt   string  `json:"updated_at"`
	Number      int     `json:"number"`
	State       string  `json:"state"`
	CreatedAt   string  `json:"created_at"`
	Trigger     Trigger `json:"trigger"`
	Vcs         Vcs     `json:"vcs"`
}

type Logger

type Logger interface {
	Printf(fmt string, args ...interface{})
}

Logger is a minimal interface for injecting custom logging logic for debug logs

type Message

type Message struct {
	Message string `json:"message"`
	Type    string `json:"type"`
}

Message represents build messages

type Node

type Node struct {
	ImageID      string `json:"image_id"`
	Port         int    `json:"port"`
	PublicIPAddr string `json:"public_ip_addr"`
	SSHEnabled   *bool  `json:"ssh_enabled"`
	Username     string `json:"username"`
}

Node represents the node a build was run on

type Output

type Output struct {
	Type    string    `json:"type"`
	Time    time.Time `json:"time"`
	Message string    `json:"message"`
}

Output represents the output of a given action

type Picard added in v0.3.0

type Picard struct {
	BuildAgent    *BuildAgent    `json:"build_agent"`
	ResourceClass *ResourceClass `json:"resource_class"`
	Executor      string         `json:"executor"`
}

Picard represents metadata about an execution environment

type Pipeline added in v0.5.0

type Pipeline struct {
	// The unique ID of the pipeline.
	ID string `json:"id"`
	// The current state of the pipeline.
	State string `json:"state"`
	// The number of the pipeline.
	Number int `json:"number"`
	// The date and time the piepeline was created.
	CreatedAt time.Time `json:"created_at"`
}

Pipeline describes a pipeline object.

type Pipelines added in v0.6.0

type Pipelines struct {
	NextPageToken interface{} `json:"next_page_token,omitempty"`
	Items         []Items     `json:"items"`
}

type Project

type Project struct {
	AWSConfig           AWSConfig         `json:"aws"`
	Branches            map[string]Branch `json:"branches"`
	CampfireNotifyPrefs *string           `json:"campfire_notify_prefs"`
	CampfireRoom        *string           `json:"campfire_room"`
	CampfireSubdomain   *string           `json:"campfire_subdomain"`
	CampfireToken       *string           `json:"campfire_token"`
	Compile             string            `json:"compile"`
	DefaultBranch       string            `json:"default_branch"`
	Dependencies        string            `json:"dependencies"`
	Extra               string            `json:"extra"`
	FeatureFlags        FeatureFlags      `json:"feature_flags"`
	FlowdockAPIToken    *string           `json:"flowdock_api_token"`
	Followed            bool              `json:"followed"`
	HallNotifyPrefs     *string           `json:"hall_notify_prefs"`
	HallRoomAPIToken    *string           `json:"hall_room_api_token"`
	HasUsableKey        bool              `json:"has_usable_key"`
	HerokuDeployUser    *string           `json:"heroku_deploy_user"`
	HipchatAPIToken     *string           `json:"hipchat_api_token"`
	HipchatNotify       *bool             `json:"hipchat_notify"`
	HipchatNotifyPrefs  *string           `json:"hipchat_notify_prefs"`
	HipchatRoom         *string           `json:"hipchat_room"`
	IrcChannel          *string           `json:"irc_channel"`
	IrcKeyword          *string           `json:"irc_keyword"`
	IrcNotifyPrefs      *string           `json:"irc_notify_prefs"`
	IrcPassword         *string           `json:"irc_password"`
	IrcServer           *string           `json:"irc_server"`
	IrcUsername         *string           `json:"irc_username"`
	Parallel            int               `json:"parallel"`
	Reponame            string            `json:"reponame"`
	Setup               string            `json:"setup"`
	SlackAPIToken       *string           `json:"slack_api_token"`
	SlackChannel        *string           `json:"slack_channel"`
	SlackNotifyPrefs    *string           `json:"slack_notify_prefs"`
	SlackSubdomain      *string           `json:"slack_subdomain"`
	SlackWebhookURL     *string           `json:"slack_webhook_url"`
	SSHKeys             []*PublicSSHKey   `json:"ssh_keys"`
	Test                string            `json:"test"`
	Username            string            `json:"username"`
	VCSURL              string            `json:"vcs_url"`
}

Project represents information about a project

type PublicSSHKey

type PublicSSHKey struct {
	Hostname    string `json:"hostname"`
	PublicKey   string `json:"public_key"`
	Fingerprint string `json:"fingerprint"`
}

PublicSSHKey represents the public part of an SSH key associated with a project PrivateKey will be a masked value

type PullRequest added in v0.3.0

type PullRequest struct {
	HeadSha string `json:"head_sha"`
	URL     string `json:"url"`
}

PullRequest represents a pull request

type ResourceClass added in v0.3.0

type ResourceClass struct {
	CPU   float64 `json:"cpu"`
	RAM   int     `json:"ram"`
	Class string  `json:"class"`
}

ResourceClass represents usable resource information for a job

type SSHUser

type SSHUser struct {
	GithubID int    `json:"github_id"`
	Login    string `json:"login"`
}

SSHUser represents a user associated with an build with SSH enabled

type Step

type Step struct {
	Name    string    `json:"name"`
	Actions []*Action `json:"actions"`
}

Step represents an individual step in a build Will contain more than one action if the step was parallelized

type TestMetadata

type TestMetadata struct {
	Classname  string  `json:"classname"`
	File       string  `json:"file"`
	Message    *string `json:"message"`
	Name       string  `json:"name"`
	Result     string  `json:"result"`
	RunTime    float64 `json:"run_time"`
	Source     string  `json:"source"`
	SourceType string  `json:"source_type"`
}

TestMetadata represents metadata collected from the test run (e.g. JUnit output)

type Trigger added in v0.6.0

type Trigger struct {
	ReceivedAt string `json:"received_at"`
	Type       string `json:"type"`
	Actor      Actor  `json:"actor"`
}

type User

type User struct {
	Admin               bool                    `json:"admin"`
	AllEmails           []string                `json:"all_emails"`
	AvatarURL           string                  `json:"avatar_url"`
	BasicEmailPrefs     string                  `json:"basic_email_prefs"`
	Containers          int                     `json:"containers"`
	CreatedAt           time.Time               `json:"created_at"`
	DaysLeftInTrial     int                     `json:"days_left_in_trial"`
	GithubID            int                     `json:"github_id"`
	GithubOauthScopes   []string                `json:"github_oauth_scopes"`
	GravatarID          *string                 `json:"gravatar_id"`
	HerokuAPIKey        *string                 `json:"heroku_api_key"`
	LastViewedChangelog time.Time               `json:"last_viewed_changelog"`
	Login               string                  `json:"login"`
	Name                *string                 `json:"name"`
	Parallelism         int                     `json:"parallelism"`
	Plan                *string                 `json:"plan"`
	Projects            map[string]*UserProject `json:"projects"`
	SelectedEmail       *string                 `json:"selected_email"`
	SignInCount         int                     `json:"sign_in_count"`
	TrialEnd            time.Time               `json:"trial_end"`
}

User represents a CircleCI user

type UserProject

type UserProject struct {
	Emails      string `json:"emails"`
	OnDashboard bool   `json:"on_dashboard"`
}

UserProject returns the selective project information included when querying for a User

type Vcs added in v0.6.0

type Vcs struct {
	OriginRepositoryURL string `json:"origin_repository_url"`
	TargetRepositoryURL string `json:"target_repository_url"`
	Revision            string `json:"revision"`
	ProviderName        string `json:"provider_name"`
	Branch              string `json:"branch"`
}

type VcsType added in v0.4.0

type VcsType string

VcsType represents the version control system type

const (
	VcsTypeGithub    VcsType = "github"
	VcsTypeBitbucket VcsType = "bitbucket"
)

VcsType constants (github and bitbucket are the currently supported choices)

type Workflow added in v0.3.0

type Workflow struct {
	JobName        string    `json:"job_name"`
	JobId          string    `json:"job_id"`
	UpstreamJobIds []*string `json:"upstream_job_ids"`
	WorkflowId     string    `json:"workflow_id"`
	WorkspaceId    string    `json:"workspace_id"`
	WorkflowName   string    `json:"workflow_name"`
}

Workflow represents the details of the workflow for a build

type WorkflowItem added in v0.5.0

type WorkflowItem struct {
	// The ID of the pipeline this workflow belongs to.
	ID string `json:"pipeline_id"`
	// The number of the pipeline this workflow belongs to.
	Number int `json:"pipeline_number"`
	// The current status of the workflow.
	Status string `json:"status"`
	// The unique ID of the workflow.
	WorkflowID string `json:"id"`
	// The name of the workflow.
	Name string `json:"name"`
	// The UUID of the person if it was canceled.
	CanceledBy string `json:"canceled_by"`
	// The UUID of the person if it was errored.
	ErroredBy string `json:"errored_by"`
	// The UUID of the person who started it.
	StartedBy string `json:"started_by"`
	// The project-slug of the pipeline this workflow belongs to.
	ProjectSlug string `json:"project_slug"`
	// The date and time the workflow was created.
	CreatedAt time.Time `json:"created_at"`
	// The date and time the workflow stopped.
	StoppedAt time.Time `json:"stopped_at"`
}

WorkflowItem represents a workflow.

type WorkflowList added in v0.5.0

type WorkflowList struct {
	// The list of workflow items.
	Items []WorkflowItem `json:"items"`
	// A token to pass as a page-token query parameter to return the next page of results.
	NextPageToken string `json:"next_page_token"`
}

WorkflowList represents a list of workflow items.

Jump to

Keyboard shortcuts

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