Documentation
¶
Index ¶
- Constants
- Variables
- func BuildVersion() string
- func FetchTags(l logger.Logger, conf FetchTagsConfig) []string
- func ParseArtifactoryDestination(destination string) (repo string, path string)
- func ParseGSDestination(destination string) (name string, path string)
- func ParseS3Destination(destination string) (name string, path string)
- func Register(l logger.Logger, ac APIClient, req api.AgentRegisterRequest) (*api.AgentRegisterResponse, error)
- func UserAgent() string
- func Version() string
- func Worker(id int, ls *LogStreamer)
- type APIClient
- type AgentConfiguration
- type AgentPool
- type AgentWorker
- func (a *AgentWorker) AcceptAndRunJob(job *api.Job) error
- func (a *AgentWorker) AcquireAndRunJob(jobId string) error
- func (a *AgentWorker) Connect() error
- func (a *AgentWorker) Disconnect() error
- func (a *AgentWorker) Heartbeat() error
- func (a *AgentWorker) Ping() (*api.Job, error)
- func (a *AgentWorker) RunJob(job *api.Job) error
- func (a *AgentWorker) Start(idleMonitor *IdleMonitor) error
- func (a *AgentWorker) Stop(graceful bool)
- type AgentWorkerConfig
- type ArtifactBatchCreator
- type ArtifactBatchCreatorConfig
- type ArtifactDownloader
- type ArtifactDownloaderConfig
- type ArtifactSearcher
- type ArtifactUploader
- type ArtifactUploaderConfig
- type ArtifactoryDownloader
- type ArtifactoryDownloaderConfig
- type ArtifactoryUploader
- type ArtifactoryUploaderConfig
- type Download
- type DownloadConfig
- type EC2MetaData
- type EC2Tags
- type Error
- type FetchTagsConfig
- type FormUploader
- type FormUploaderConfig
- type GCPLabels
- type GCPMetaData
- type GSDownloader
- type GSDownloaderConfig
- type GSUploader
- type GSUploaderConfig
- type IdleMonitor
- type JobRunner
- type JobRunnerConfig
- type LogStreamer
- type LogStreamerChunk
- type LogStreamerConfig
- type PipelineParser
- type PipelineParserResult
- type S3Downloader
- type S3DownloaderConfig
- type S3Uploader
- type S3UploaderConfig
- type Uploader
Constants ¶
const ( ArtifactPathDelimiter = ";" ArtifactFallbackMimeType = "binary/octet-stream" )
const ( // BuildkiteMessageMax is the maximum length of "BUILDKITE_MESSAGE=...\0" // environment entry passed to bootstrap, beyond which it will be truncated // to avoid exceeding the system limit. Note that it includes the variable // name, equals sign, and null terminator. // // The true limit varies by system and may be shared with other env/argv // data. We'll settle on an arbitrary generous but reasonable value, and // adjust it if issues arise. // // macOS 10.15: 256 KiB shared by environment & argv // Linux 4.19: 128 KiB per k=v env // Windows 10: 16,384 KiB shared // POSIX: 4 KiB minimum shared BuildkiteMessageMax = 64 * 1024 // BuildkiteMessageName is the env var name of the build/commit message. BuildkiteMessageName = "BUILDKITE_MESSAGE" )
Variables ¶
var ArtifactPathVariableRegex = regexp.MustCompile("\\$\\{artifact\\:path\\}")
Functions ¶
func BuildVersion ¶
func BuildVersion() string
func FetchTags ¶
func FetchTags(l logger.Logger, conf FetchTagsConfig) []string
FetchTags loads tags from a variety of sources
func ParseGSDestination ¶
func ParseS3Destination ¶
func Register ¶
func Register(l logger.Logger, ac APIClient, req api.AgentRegisterRequest) (*api.AgentRegisterResponse, error)
Register takes an api.Agent and registers it with the Buildkite API and populates the result of the register call
Types ¶
type APIClient ¶
type APIClient interface {
AcceptJob(*api.Job) (*api.Job, *api.Response, error)
AcquireJob(string) (*api.Job, *api.Response, error)
Annotate(string, *api.Annotation) (*api.Response, error)
Config() api.Config
Connect() (*api.Response, error)
CreateArtifacts(string, *api.ArtifactBatch) (*api.ArtifactBatchCreateResponse, *api.Response, error)
Disconnect() (*api.Response, error)
ExistsMetaData(string, string) (*api.MetaDataExists, *api.Response, error)
FinishJob(*api.Job) (*api.Response, error)
FromAgentRegisterResponse(*api.AgentRegisterResponse) *api.Client
FromPing(*api.Ping) *api.Client
GetJobState(string) (*api.JobState, *api.Response, error)
GetMetaData(string, string) (*api.MetaData, *api.Response, error)
Heartbeat() (*api.Heartbeat, *api.Response, error)
Ping() (*api.Ping, *api.Response, error)
Register(*api.AgentRegisterRequest) (*api.AgentRegisterResponse, *api.Response, error)
SaveHeaderTimes(string, *api.HeaderTimes) (*api.Response, error)
SearchArtifacts(string, *api.ArtifactSearchOptions) ([]*api.Artifact, *api.Response, error)
SetMetaData(string, *api.MetaData) (*api.Response, error)
StartJob(*api.Job) (*api.Response, error)
StepUpdate(string, *api.StepUpdate) (*api.Response, error)
UpdateArtifacts(string, map[string]string) (*api.Response, error)
UploadChunk(string, *api.Chunk) (*api.Response, error)
UploadPipeline(string, *api.Pipeline) (*api.Response, error)
}
APIClient is an interface generated for "github.com/buildkite/agent/v3/api.Client".
type AgentConfiguration ¶
type AgentConfiguration struct {
ConfigPath string
BootstrapScript string
BuildPath string
HooksPath string
GitMirrorsPath string
GitMirrorsLockTimeout int
PluginsPath string
GitCloneFlags string
GitCloneMirrorFlags string
GitCleanFlags string
GitFetchFlags string
GitSubmodules bool
SSHKeyscan bool
CommandEval bool
PluginsEnabled bool
PluginValidation bool
LocalHooksEnabled bool
RunInPty bool
TimestampLines bool
HealthCheckAddr string
DisconnectAfterJob bool
DisconnectAfterIdleTimeout int
CancelGracePeriod int
Shell string
Profile string
RedactedVars []string
AcquireJob string
}
AgentConfiguration is the run-time configuration for an agent that has been loaded from the config file and command-line params
type AgentPool ¶
type AgentPool struct {
// contains filtered or unexported fields
}
AgentPool manages multiple parallel AgentWorkers
func NewAgentPool ¶
func NewAgentPool(workers []*AgentWorker) *AgentPool
NewAgentPool returns a new AgentPool
type AgentWorker ¶
type AgentWorker struct {
// contains filtered or unexported fields
}
func NewAgentWorker ¶
func NewAgentWorker(l logger.Logger, a *api.AgentRegisterResponse, m *metrics.Collector, apiClient APIClient, c AgentWorkerConfig) *AgentWorker
Creates the agent worker and initializes its API Client
func (*AgentWorker) AcceptAndRunJob ¶
func (a *AgentWorker) AcceptAndRunJob(job *api.Job) error
Accepts a job and runs it, only returns an error if something goes wrong
func (*AgentWorker) AcquireAndRunJob ¶
func (a *AgentWorker) AcquireAndRunJob(jobId string) error
Attempts to acquire a job and run it, only returns an error if something goes wrong
func (*AgentWorker) Connect ¶
func (a *AgentWorker) Connect() error
Connects the agent to the Buildkite Agent API, retrying up to 30 times if it fails.
func (*AgentWorker) Disconnect ¶
func (a *AgentWorker) Disconnect() error
Disconnects the agent from the Buildkite Agent API, doesn't bother retrying because we want to disconnect as fast as possible.
func (*AgentWorker) Ping ¶
func (a *AgentWorker) Ping() (*api.Job, error)
Performs a ping that checks Buildkite for a job or action to take Returns a job, or nil if none is found
func (*AgentWorker) Start ¶
func (a *AgentWorker) Start(idleMonitor *IdleMonitor) error
Starts the agent worker
func (*AgentWorker) Stop ¶
func (a *AgentWorker) Stop(graceful bool)
Stops the agent from accepting new work and cancels any current work it's running
type AgentWorkerConfig ¶
type AgentWorkerConfig struct {
// Whether to set debug in the job
Debug bool
// Whether to set debugHTTP in the job
DebugHTTP bool
// What signal to use for worker cancellation
CancelSignal process.Signal
// The index of this agent worker
SpawnIndex int
// The configuration of the agent from the CLI
AgentConfiguration AgentConfiguration
}
type ArtifactBatchCreator ¶
type ArtifactBatchCreator struct {
// contains filtered or unexported fields
}
func NewArtifactBatchCreator ¶
func NewArtifactBatchCreator(l logger.Logger, ac APIClient, c ArtifactBatchCreatorConfig) *ArtifactBatchCreator
type ArtifactDownloader ¶
type ArtifactDownloader struct {
// contains filtered or unexported fields
}
func NewArtifactDownloader ¶
func NewArtifactDownloader(l logger.Logger, ac APIClient, c ArtifactDownloaderConfig) ArtifactDownloader
func (*ArtifactDownloader) Download ¶
func (a *ArtifactDownloader) Download() error
type ArtifactDownloaderConfig ¶
type ArtifactDownloaderConfig struct {
// The ID of the Build
BuildID string
// The query used to find the artifacts
Query string
// Which step should we look at for the jobs
Step string
// Whether to include artifacts from retried jobs in the search
IncludeRetriedJobs bool
// Where we'll be downloading artifacts to
Destination string
// Whether to show HTTP debugging
DebugHTTP bool
}
type ArtifactSearcher ¶
type ArtifactSearcher struct {
// contains filtered or unexported fields
}
func NewArtifactSearcher ¶
func NewArtifactSearcher(l logger.Logger, ac APIClient, buildID string) *ArtifactSearcher
type ArtifactUploader ¶
type ArtifactUploader struct {
// contains filtered or unexported fields
}
func NewArtifactUploader ¶
func NewArtifactUploader(l logger.Logger, ac APIClient, c ArtifactUploaderConfig) *ArtifactUploader
func (*ArtifactUploader) Collect ¶
func (a *ArtifactUploader) Collect() (artifacts []*api.Artifact, err error)
func (*ArtifactUploader) Upload ¶
func (a *ArtifactUploader) Upload() error
type ArtifactUploaderConfig ¶
type ArtifactoryDownloader ¶
type ArtifactoryDownloader struct {
// contains filtered or unexported fields
}
func NewArtifactoryDownloader ¶
func NewArtifactoryDownloader(l logger.Logger, c ArtifactoryDownloaderConfig) *ArtifactoryDownloader
func (ArtifactoryDownloader) RepositoryFileLocation ¶
func (d ArtifactoryDownloader) RepositoryFileLocation() string
func (ArtifactoryDownloader) RepositoryName ¶
func (d ArtifactoryDownloader) RepositoryName() string
func (ArtifactoryDownloader) RepositoryPath ¶
func (d ArtifactoryDownloader) RepositoryPath() string
func (ArtifactoryDownloader) Start ¶
func (d ArtifactoryDownloader) Start() error
type ArtifactoryDownloaderConfig ¶
type ArtifactoryDownloaderConfig struct {
// The Artifactory repository name and the path, e.g rt://my-repo-name/foo/bar
Repository string
// The root directory of the download
Destination string
// The relative path that should be preserved in the download folder,
// also its location in the repo
Path string
// How many times should it retry the download before giving up
Retries int
// If failed responses should be dumped to the log
DebugHTTP bool
}
type ArtifactoryUploader ¶
type ArtifactoryUploader struct {
// The artifactory bucket path set from the destination
Path string
// The artifactory bucket name set from the destination
Repository string
// contains filtered or unexported fields
}
func NewArtifactoryUploader ¶
func NewArtifactoryUploader(l logger.Logger, c ArtifactoryUploaderConfig) (*ArtifactoryUploader, error)
type Download ¶
type Download struct {
// contains filtered or unexported fields
}
func NewDownload ¶
type DownloadConfig ¶
type DownloadConfig struct {
// The actual URL to get the file from
URL string
// The root directory of the download
Destination string
// Optional Headers to append to the request
Headers map[string]string
// The relative path that should be preserved in the download folder
Path string
// How many times should it retry the download before giving up
Retries int
// If failed responses should be dumped to the log
DebugHTTP bool
}
type EC2MetaData ¶
type EC2MetaData struct {
}
type Error ¶
type Error struct {
Status int `json:"status"` // Error code
Message string `json:"message"` // Message describing the error.
}
An Error reports more details on an individual error in an ErrorResponse.
type FetchTagsConfig ¶
type FormUploader ¶
type FormUploader struct {
// contains filtered or unexported fields
}
func NewFormUploader ¶
func NewFormUploader(l logger.Logger, c FormUploaderConfig) *FormUploader
type FormUploaderConfig ¶
type FormUploaderConfig struct {
// Whether or not HTTP calls should be debugged
DebugHTTP bool
}
type GCPMetaData ¶
type GCPMetaData struct {
}
type GSDownloader ¶
type GSDownloader struct {
// contains filtered or unexported fields
}
func NewGSDownloader ¶
func NewGSDownloader(l logger.Logger, c GSDownloaderConfig) *GSDownloader
func (GSDownloader) BucketFileLocation ¶
func (d GSDownloader) BucketFileLocation() string
func (GSDownloader) BucketName ¶
func (d GSDownloader) BucketName() string
func (GSDownloader) BucketPath ¶
func (d GSDownloader) BucketPath() string
func (GSDownloader) Start ¶
func (d GSDownloader) Start() error
type GSDownloaderConfig ¶
type GSDownloaderConfig struct {
// The name of the bucket
Bucket string
// The root directory of the download
Destination string
// The relative path that should be preserved in the download folder,
// also its location in the bucket
Path string
// How many times should it retry the download before giving up
Retries int
// If failed responses should be dumped to the log
DebugHTTP bool
}
type GSUploader ¶
type GSUploader struct {
// The gs bucket path set from the destination
BucketPath string
// The gs bucket name set from the destination
BucketName string
// contains filtered or unexported fields
}
func NewGSUploader ¶
func NewGSUploader(l logger.Logger, c GSUploaderConfig) (*GSUploader, error)
type GSUploaderConfig ¶
type IdleMonitor ¶
func NewIdleMonitor ¶
func NewIdleMonitor(totalAgents int) *IdleMonitor
func (*IdleMonitor) Idle ¶
func (i *IdleMonitor) Idle() bool
func (*IdleMonitor) MarkBusy ¶
func (i *IdleMonitor) MarkBusy(agentUUID string)
func (*IdleMonitor) MarkIdle ¶
func (i *IdleMonitor) MarkIdle(agentUUID string)
type JobRunner ¶
type JobRunner struct {
// contains filtered or unexported fields
}
func NewJobRunner ¶
func NewJobRunner(l logger.Logger, scope *metrics.Scope, ag *api.AgentRegisterResponse, j *api.Job, apiClient APIClient, conf JobRunnerConfig) (*JobRunner, error)
Initializes the job runner
func (*JobRunner) CancelAndStop ¶ added in v3.21.0
type JobRunnerConfig ¶
type JobRunnerConfig struct {
// The configuration of the agent from the CLI
AgentConfiguration AgentConfiguration
// What signal to use for worker cancellation
CancelSignal process.Signal
// Whether to set debug in the job
Debug bool
// Whether to set debug HTTP Requests in the job
DebugHTTP bool
}
type LogStreamer ¶
type LogStreamer struct {
// contains filtered or unexported fields
}
func NewLogStreamer ¶
func NewLogStreamer(l logger.Logger, cb func(chunk *LogStreamerChunk) error, c LogStreamerConfig) *LogStreamer
Creates a new instance of the log streamer
func (*LogStreamer) FailedChunks ¶
func (ls *LogStreamer) FailedChunks() int
func (*LogStreamer) Process ¶
func (ls *LogStreamer) Process(output string) error
Takes the full process output, grabs the portion we don't have, and adds it to the stream queue
func (*LogStreamer) Start ¶
func (ls *LogStreamer) Start() error
Spins up x number of log streamer workers
func (*LogStreamer) Stop ¶
func (ls *LogStreamer) Stop() error
Waits for all the chunks to be uploaded, then shuts down all the workers
type LogStreamerChunk ¶
type LogStreamerConfig ¶
type PipelineParser ¶
type PipelineParser struct {
Env *env.Environment
Filename string
Pipeline []byte
NoInterpolation bool
}
func (PipelineParser) Parse ¶
func (p PipelineParser) Parse() (*PipelineParserResult, error)
type PipelineParserResult ¶
type PipelineParserResult struct {
// contains filtered or unexported fields
}
PipelineParserResult is the ordered parse tree of a Pipeline document
func (*PipelineParserResult) MarshalJSON ¶
func (p *PipelineParserResult) MarshalJSON() ([]byte, error)
type S3Downloader ¶
type S3Downloader struct {
// contains filtered or unexported fields
}
func NewS3Downloader ¶
func NewS3Downloader(l logger.Logger, c S3DownloaderConfig) *S3Downloader
func (S3Downloader) BucketFileLocation ¶
func (d S3Downloader) BucketFileLocation() string
func (S3Downloader) BucketName ¶
func (d S3Downloader) BucketName() string
func (S3Downloader) BucketPath ¶
func (d S3Downloader) BucketPath() string
func (S3Downloader) Start ¶
func (d S3Downloader) Start() error
type S3DownloaderConfig ¶
type S3DownloaderConfig struct {
// The S3 bucket name and the path, e.g s3://my-bucket-name/foo/bar
Bucket string
// The root directory of the download
Destination string
// The relative path that should be preserved in the download folder,
// also its location in the bucket
Path string
// How many times should it retry the download before giving up
Retries int
// If failed responses should be dumped to the log
DebugHTTP bool
}
type S3Uploader ¶
type S3Uploader struct {
// The s3 bucket path set from the destination
BucketPath string
// The s3 bucket name set from the destination
BucketName string
// contains filtered or unexported fields
}
func NewS3Uploader ¶
func NewS3Uploader(l logger.Logger, c S3UploaderConfig) (*S3Uploader, error)
type S3UploaderConfig ¶
Source Files
¶
- agent_configuration.go
- agent_pool.go
- agent_worker.go
- api.go
- artifact_batch_creator.go
- artifact_downloader.go
- artifact_searcher.go
- artifact_uploader.go
- arty_downloader.go
- arty_uploader.go
- aws.go
- download.go
- ec2_meta_data.go
- ec2_tags.go
- form_uploader.go
- gcp_labels.go
- gcp_meta_data.go
- gs_downloader.go
- gs_uploader.go
- header_times_streamer.go
- job_runner.go
- log_streamer.go
- pipeline_parser.go
- register.go
- s3.go
- s3_downloader.go
- s3_uploader.go
- tags.go
- uploader.go
- version.go