Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateShellScript(scriptType ShellScriptType, info ShellScriptInfo) (string, error)
- func GetCommands() []cli.Command
- func GetDefaultShell() string
- func GetExecutors() []string
- func GetShells() []string
- func RegisterCommand(command cli.Command)
- func RegisterCommand2(name, usage string, data Commander, flags ...cli.Flag)
- func RegisterExecutor(executor string, provider ExecutorProvider)
- func RegisterShell(shell Shell)
- type AppVersionInfo
- type Build
- func (b *Build) FullProjectDir() string
- func (b *Build) GetAllVariables() BuildVariables
- func (b *Build) GetDefaultVariables() BuildVariables
- func (b *Build) GetGitDepth() string
- func (b *Build) GetGitStrategy() GitStrategy
- func (b *Build) Log() *logrus.Entry
- func (b *Build) ProjectSlug() (string, error)
- func (b *Build) ProjectUniqueDir(sharedDir bool) string
- func (b *Build) ProjectUniqueName() string
- func (b *Build) Run(globalConfig *Config, trace BuildTrace) (err error)
- func (b *Build) StartBuild(rootDir, cacheDir string, sharedDir bool)
- func (b *Build) String() string
- type BuildArtifacts
- type BuildCredentials
- type BuildError
- type BuildInfo
- type BuildLogger
- func (e *BuildLogger) Debugln(args ...interface{})
- func (e *BuildLogger) Errorln(args ...interface{})
- func (e *BuildLogger) Infoln(args ...interface{})
- func (e *BuildLogger) Println(args ...interface{})
- func (e *BuildLogger) SoftErrorln(args ...interface{})
- func (e *BuildLogger) Warningln(args ...interface{})
- type BuildOptions
- func (m *BuildOptions) Decode(result interface{}, keys ...string) error
- func (m *BuildOptions) Get(keys ...string) (interface{}, bool)
- func (m *BuildOptions) GetString(keys ...string) (result string, ok bool)
- func (m *BuildOptions) GetSubOptions(keys ...string) (result BuildOptions, ok bool)
- func (m *BuildOptions) Sanitize() (err error)
- type BuildState
- type BuildTrace
- type BuildTracePatch
- type BuildVariable
- type BuildVariables
- type CacheConfig
- type Commander
- type Config
- type DeleteRunnerRequest
- type DockerConfig
- type DockerMachine
- type DockerPullPolicy
- type DownloadState
- type Executor
- type ExecutorCommand
- type ExecutorData
- type ExecutorProvider
- type FeaturesInfo
- type GetBuildRequest
- type GetBuildResponse
- type GitStrategy
- type Network
- type ParallelsConfig
- type RegisterRunnerRequest
- type RegisterRunnerResponse
- type RunnerConfig
- type RunnerCredentials
- type RunnerSettings
- type Shell
- type ShellConfiguration
- type ShellScriptInfo
- type ShellScriptType
- type ShellType
- type Trace
- type UpdateBuildRequest
- type UpdateState
- type UploadState
- type VerifyRunnerRequest
- type VersionInfo
- type VirtualBoxConfig
Constants ¶
View Source
const ( Pending BuildState = "pending" Running = "running" Failed = "failed" Success = "success" )
View Source
const ( DockerPullPolicyAlways DockerPullPolicy = "always" DockerPullPolicyNever = "never" DockerPullPolicyIfNotPresent = "if-not-present" )
View Source
const ( ShellPrepareScript ShellScriptType = "prepare_script" ShellBuildScript = "build_script" ShellAfterScript = "after_script" ShellArchiveCache = "archive_cache" ShellUploadArtifacts = "upload_artifacts" )
View Source
const CheckInterval = 3 * time.Second
View Source
const DefaultExecTimeout = 1800
View Source
const DefaultOutputLimit = 4096 // 4MB in kilobytes
View Source
const DefaultTimeout = 7200
View Source
const DefaultWaitForServicesTimeout = 30
View Source
const ForceTraceSentInterval = 30 * time.Second
View Source
const HealthCheckInterval = 3600
View Source
const HealthyChecks = 3
View Source
const NotHealthyCheckInterval = 300
View Source
const ReloadConfigInterval = 3
View Source
const ShutdownTimeout = 30
View Source
const UpdateInterval = 3 * time.Second
View Source
const UpdateRetryInterval = 3 * time.Second
Variables ¶
View Source
var BRANCH = "HEAD"
View Source
var BUILT = "now"
View Source
var FailedBuild = GetBuildResponse{
RepoURL: repoURL,
Commands: "exit 1",
Sha: repoSHA,
BeforeSha: repoBeforeSHA,
RefName: repoRefName,
}
View Source
var LongRunningBuild = GetBuildResponse{
RepoURL: repoURL,
Commands: "sleep 3600",
Sha: repoSHA,
BeforeSha: repoBeforeSHA,
RefName: repoRefName,
}
View Source
var NAME = "gitlab-ci-multi-runner"
View Source
var REVISION = "HEAD"
View Source
var SuccessfulBuild = GetBuildResponse{
RepoURL: repoURL,
Commands: "echo Hello World",
Sha: repoSHA,
BeforeSha: repoBeforeSHA,
RefName: repoRefName,
}
View Source
var VERSION = "dev"
Functions ¶
func GenerateShellScript ¶
func GenerateShellScript(scriptType ShellScriptType, info ShellScriptInfo) (string, error)
func GetCommands ¶
func GetDefaultShell ¶
func GetDefaultShell() string
func GetExecutors ¶
func GetExecutors() []string
func RegisterCommand ¶
func RegisterCommand2 ¶
func RegisterExecutor ¶
func RegisterExecutor(executor string, provider ExecutorProvider)
func RegisterShell ¶
func RegisterShell(shell Shell)
Types ¶
type AppVersionInfo ¶ added in v1.4.0
type AppVersionInfo struct { Name string `json:"name"` Version string `json:"version"` Revision string `json:"revision"` Branch string `json:"branch"` GOVersion string `json:"go_version"` BuiltAt time.Time `json:"built_at"` OS string `json:"os"` Architecture string `json:"architecture"` }
var AppVersion AppVersionInfo
func (*AppVersionInfo) Extended ¶ added in v1.4.0
func (v *AppVersionInfo) Extended() string
func (*AppVersionInfo) Line ¶ added in v1.4.0
func (v *AppVersionInfo) Line() string
func (*AppVersionInfo) Printer ¶ added in v1.4.0
func (v *AppVersionInfo) Printer(c *cli.Context)
func (*AppVersionInfo) ShortLine ¶ added in v1.4.0
func (v *AppVersionInfo) ShortLine() string
func (*AppVersionInfo) UserAgent ¶ added in v1.4.0
func (v *AppVersionInfo) UserAgent() string
type Build ¶
type Build struct { GetBuildResponse `yaml:",inline"` Trace BuildTrace SystemInterrupt chan os.Signal `json:"-" yaml:"-"` RootDir string `json:"-" yaml:"-"` BuildDir string `json:"-" yaml:"-"` CacheDir string `json:"-" yaml:"-"` Hostname string `json:"-" yaml:"-"` Runner *RunnerConfig `json:"runner"` ExecutorData ExecutorData // Unique ID for all running builds on this runner RunnerID int `json:"runner_id"` // Unique ID for all running builds on this runner and this project ProjectRunnerID int `json:"project_runner_id"` }
func (*Build) FullProjectDir ¶
func (*Build) GetAllVariables ¶
func (b *Build) GetAllVariables() BuildVariables
func (*Build) GetDefaultVariables ¶
func (b *Build) GetDefaultVariables() BuildVariables
func (*Build) GetGitDepth ¶ added in v1.3.0
func (*Build) GetGitStrategy ¶ added in v1.3.0
func (b *Build) GetGitStrategy() GitStrategy
func (*Build) ProjectSlug ¶
func (*Build) ProjectUniqueDir ¶
func (*Build) ProjectUniqueName ¶
func (*Build) StartBuild ¶
type BuildArtifacts ¶
type BuildCredentials ¶
type BuildCredentials struct { ID int `long:"id" env:"CI_BUILD_ID" description:"The build ID to upload artifacts for"` Token string `long:"token" env:"CI_BUILD_TOKEN" required:"true" description:"Build token"` URL string `long:"url" env:"CI_SERVER_URL" required:"true" description:"GitLab CI URL"` TLSCAFile string `` /* 129-byte string literal not displayed */ }
type BuildError ¶ added in v1.4.0
type BuildError struct {
Inner error
}
func (*BuildError) Error ¶ added in v1.4.0
func (b *BuildError) Error() string
type BuildLogger ¶ added in v1.4.0
type BuildLogger struct {
// contains filtered or unexported fields
}
func NewBuildLogger ¶ added in v1.4.0
func NewBuildLogger(log BuildTrace, entry *logrus.Entry) BuildLogger
func (*BuildLogger) Debugln ¶ added in v1.4.0
func (e *BuildLogger) Debugln(args ...interface{})
func (*BuildLogger) Errorln ¶ added in v1.4.0
func (e *BuildLogger) Errorln(args ...interface{})
func (*BuildLogger) Infoln ¶ added in v1.4.0
func (e *BuildLogger) Infoln(args ...interface{})
func (*BuildLogger) Println ¶ added in v1.4.0
func (e *BuildLogger) Println(args ...interface{})
func (*BuildLogger) SoftErrorln ¶ added in v1.4.0
func (e *BuildLogger) SoftErrorln(args ...interface{})
func (*BuildLogger) Warningln ¶ added in v1.4.0
func (e *BuildLogger) Warningln(args ...interface{})
type BuildOptions ¶
type BuildOptions map[string]interface{}
func (*BuildOptions) Decode ¶
func (m *BuildOptions) Decode(result interface{}, keys ...string) error
func (*BuildOptions) Get ¶
func (m *BuildOptions) Get(keys ...string) (interface{}, bool)
func (*BuildOptions) GetString ¶
func (m *BuildOptions) GetString(keys ...string) (result string, ok bool)
func (*BuildOptions) GetSubOptions ¶ added in v1.1.1
func (m *BuildOptions) GetSubOptions(keys ...string) (result BuildOptions, ok bool)
func (*BuildOptions) Sanitize ¶ added in v1.1.1
func (m *BuildOptions) Sanitize() (err error)
type BuildState ¶
type BuildState string
type BuildTrace ¶
type BuildTracePatch ¶ added in v1.3.0
type BuildVariable ¶
type BuildVariable struct { Key string `json:"key"` Value string `json:"value"` Public bool `json:"public"` Internal bool `json:"-"` File bool `json:"-"` }
func ParseVariable ¶
func ParseVariable(text string) (variable BuildVariable, err error)
func (BuildVariable) String ¶
func (b BuildVariable) String() string
type BuildVariables ¶
type BuildVariables []BuildVariable
func (BuildVariables) Expand ¶
func (b BuildVariables) Expand() (variables BuildVariables)
func (BuildVariables) ExpandValue ¶
func (b BuildVariables) ExpandValue(value string) string
func (BuildVariables) Get ¶
func (b BuildVariables) Get(key string) string
func (BuildVariables) PublicOrInternal ¶
func (b BuildVariables) PublicOrInternal() (variables BuildVariables)
func (BuildVariables) StringList ¶
func (b BuildVariables) StringList() (variables []string)
type CacheConfig ¶
type CacheConfig struct { Type string `toml:"Type,omitempty" long:"type" env:"CACHE_TYPE" description:"Select caching method: s3, to use S3 buckets"` ServerAddress string `toml:"ServerAddress,omitempty" long:"s3-server-address" env:"S3_SERVER_ADDRESS" description:"S3 Server Address"` AccessKey string `toml:"AccessKey,omitempty" long:"s3-access-key" env:"S3_ACCESS_KEY" description:"S3 Access Key"` SecretKey string `toml:"SecretKey,omitempty" long:"s3-secret-key" env:"S3_SECRET_KEY" description:"S3 Secret Key"` BucketName string `toml:"BucketName,omitempty" long:"s3-bucket-name" env:"S3_BUCKET_NAME" description:"S3 bucket name"` BucketLocation string `toml:"BucketLocation,omitempty" long:"s3-bucket-location" env:"S3_BUCKET_LOCATION" description:"S3 location"` Insecure bool `toml:"Insecure,omitempty" long:"s3-insecure" env:"S3_CACHE_INSECURE" description:"Use insecure mode (without https)"` }
type Config ¶
type Config struct { Concurrent int `toml:"concurrent" json:"concurrent"` CheckInterval int `toml:"check_interval" json:"check_interval" description:"Define active checking interval of jobs"` User string `toml:"user,omitempty" json:"user"` Runners []*RunnerConfig `toml:"runners" json:"runners"` SentryDSN *string `toml:"sentry_dsn"` ModTime time.Time `toml:"-"` Loaded bool `toml:"-"` }
func (*Config) GetCheckInterval ¶ added in v1.3.0
func (*Config) LoadConfig ¶
func (*Config) SaveConfig ¶
func (*Config) StatConfig ¶
type DeleteRunnerRequest ¶
type DeleteRunnerRequest struct {
Token string `json:"token,omitempty"`
}
type DockerConfig ¶
type DockerConfig struct { docker_helpers.DockerCredentials Hostname string `toml:"hostname,omitempty" json:"hostname" long:"hostname" env:"DOCKER_HOSTNAME" description:"Custom container hostname"` Image string `toml:"image" json:"image" long:"image" env:"DOCKER_IMAGE" description:"Docker image to be used"` CPUSetCPUs string `` /* 159-byte string literal not displayed */ DNS []string `toml:"dns,omitempty" json:"dns" long:"dns" env:"DOCKER_DNS" description:"A list of DNS servers for the container to use"` DNSSearch []string `` /* 130-byte string literal not displayed */ Privileged bool `` /* 138-byte string literal not displayed */ CapAdd []string `toml:"cap_add" json:"cap_add" long:"cap-add" env:"DOCKER_CAP_ADD" description:"Add Linux capabilities"` CapDrop []string `toml:"cap_drop" json:"cap_drop" long:"cap-drop" env:"DOCKER_CAP_DROP" description:"Drop Linux capabilities"` SecurityOpt []string `toml:"security_opt" json:"security_opt" long:"security-opt" env:"DOCKER_SECURITY_OPT" description:"Security Options"` Devices []string `toml:"devices" json:"devices" long:"devices" env:"DOCKER_DEVICES" description:"Add a host device to the container"` DisableCache bool `` /* 142-byte string literal not displayed */ Volumes []string `toml:"volumes,omitempty" json:"volumes" long:"volumes" env:"DOCKER_VOLUMES" description:"Bind mount a volumes"` CacheDir string `` /* 129-byte string literal not displayed */ ExtraHosts []string `` /* 137-byte string literal not displayed */ NetworkMode string `` /* 143-byte string literal not displayed */ Links []string `toml:"links,omitempty" json:"links" long:"links" env:"DOCKER_LINKS" description:"Add link to another container"` Services []string `` /* 136-byte string literal not displayed */ WaitForServicesTimeout int `` /* 197-byte string literal not displayed */ AllowedImages []string `` /* 142-byte string literal not displayed */ AllowedServices []string `` /* 152-byte string literal not displayed */ PullPolicy DockerPullPolicy `` /* 154-byte string literal not displayed */ }
type DockerMachine ¶
type DockerMachine struct { IdleCount int `long:"idle-nodes" env:"MACHINE_IDLE_COUNT" description:"Maximum idle machines"` IdleTime int `toml:"IdleTime,omitzero" long:"idle-time" env:"MACHINE_IDLE_TIME" description:"Minimum time after node can be destroyed"` MaxBuilds int `` /* 128-byte string literal not displayed */ MachineDriver string `long:"machine-driver" env:"MACHINE_DRIVER" description:"The driver to use when creating machine"` MachineName string `long:"machine-name" env:"MACHINE_NAME" description:"The template for machine name (needs to include %s)"` MachineOptions []string `long:"machine-options" env:"MACHINE_OPTIONS" description:"Additional machine creation options"` }
type DockerPullPolicy ¶
type DockerPullPolicy string
func (DockerPullPolicy) Get ¶
func (p DockerPullPolicy) Get() (DockerPullPolicy, error)
Get returns one of the predefined values or returns an error if the value can't match the predefined
type DownloadState ¶
type DownloadState int
const ( DownloadSucceeded DownloadState = iota DownloadForbidden DownloadFailed DownloadNotFound )
type Executor ¶
type Executor interface { Shell() *ShellScriptInfo Prepare(globalConfig *Config, config *RunnerConfig, build *Build) error Run(cmd ExecutorCommand) error Finish(err error) Cleanup() }
func NewExecutor ¶
type ExecutorCommand ¶ added in v1.2.0
type ExecutorData ¶
type ExecutorData interface{}
type ExecutorProvider ¶
type ExecutorProvider interface { CanCreate() bool Create() Executor Acquire(config *RunnerConfig) (ExecutorData, error) Release(config *RunnerConfig, data ExecutorData) error GetFeatures(features *FeaturesInfo) }
func GetExecutor ¶
func GetExecutor(executor string) ExecutorProvider
type FeaturesInfo ¶
type GetBuildRequest ¶
type GetBuildRequest struct { Info VersionInfo `json:"info,omitempty"` Token string `json:"token,omitempty"` }
type GetBuildResponse ¶
type GetBuildResponse struct { ID int `json:"id,omitempty"` ProjectID int `json:"project_id,omitempty"` Commands string `json:"commands,omitempty"` RepoURL string `json:"repo_url,omitempty"` Sha string `json:"sha,omitempty"` RefName string `json:"ref,omitempty"` BeforeSha string `json:"before_sha,omitempty"` AllowGitFetch bool `json:"allow_git_fetch,omitempty"` Timeout int `json:"timeout,omitempty"` Variables BuildVariables `json:"variables"` Options BuildOptions `json:"options"` Token string `json:"token"` Name string `json:"name"` Stage string `json:"stage"` Tag bool `json:"tag"` DependsOnBuilds []BuildInfo `json:"depends_on_builds"` TLSCAChain string `json:"-"` }
func (*GetBuildResponse) RepoCleanURL ¶ added in v1.4.0
func (b *GetBuildResponse) RepoCleanURL() string
type GitStrategy ¶ added in v1.3.0
type GitStrategy int
const ( GitClone GitStrategy = iota GitFetch )
type Network ¶
type Network interface { GetBuild(config RunnerConfig) (*GetBuildResponse, bool) RegisterRunner(config RunnerCredentials, description, tags string) *RegisterRunnerResponse DeleteRunner(config RunnerCredentials) bool VerifyRunner(config RunnerCredentials) bool UpdateBuild(config RunnerConfig, id int, state BuildState, trace *string) UpdateState PatchTrace(config RunnerConfig, buildCredentials *BuildCredentials, tracePart BuildTracePatch) UpdateState DownloadArtifacts(config BuildCredentials, artifactsFile string) DownloadState UploadRawArtifacts(config BuildCredentials, reader io.Reader, baseName string, expireIn string) UploadState UploadArtifacts(config BuildCredentials, artifactsFile string) UploadState ProcessBuild(config RunnerConfig, buildCredentials *BuildCredentials) BuildTrace }
type ParallelsConfig ¶
type RegisterRunnerRequest ¶
type RegisterRunnerRequest struct { Info VersionInfo `json:"info,omitempty"` Token string `json:"token,omitempty"` Description string `json:"description,omitempty"` Tags string `json:"tag_list,omitempty"` }
type RegisterRunnerResponse ¶
type RegisterRunnerResponse struct {
Token string `json:"token,omitempty"`
}
type RunnerConfig ¶
type RunnerConfig struct { Name string `toml:"name" json:"name" short:"name" long:"description" env:"RUNNER_NAME" description:"Runner name"` Limit int `` /* 130-byte string literal not displayed */ OutputLimit int `` /* 126-byte string literal not displayed */ RunnerCredentials RunnerSettings }
func (*RunnerConfig) GetVariables ¶
func (c *RunnerConfig) GetVariables() BuildVariables
func (*RunnerConfig) String ¶
func (c *RunnerConfig) String() string
type RunnerCredentials ¶
type RunnerCredentials struct { URL string `toml:"url" json:"url" short:"u" long:"url" env:"CI_SERVER_URL" required:"true" description:"Runner URL"` Token string `toml:"token" json:"token" short:"t" long:"token" env:"CI_SERVER_TOKEN" required:"true" description:"Runner token"` TLSCAFile string `` /* 177-byte string literal not displayed */ }
func (*RunnerCredentials) Log ¶
func (c *RunnerCredentials) Log() *log.Entry
func (*RunnerCredentials) ShortDescription ¶
func (c *RunnerCredentials) ShortDescription() string
func (*RunnerCredentials) UniqueID ¶
func (c *RunnerCredentials) UniqueID() string
type RunnerSettings ¶
type RunnerSettings struct { Executor string `` /* 140-byte string literal not displayed */ BuildsDir string `` /* 135-byte string literal not displayed */ CacheDir string `` /* 135-byte string literal not displayed */ Environment []string `` /* 148-byte string literal not displayed */ Shell string `toml:"shell,omitempty" json:"shell" long:"shell" env:"RUNNER_SHELL" description:"Select bash, cmd or powershell"` SSH *ssh.Config `toml:"ssh" json:"ssh" group:"ssh executor" namespace:"ssh"` Docker *DockerConfig `toml:"docker" json:"docker" group:"docker executor" namespace:"docker"` Parallels *ParallelsConfig `toml:"parallels" json:"parallels" group:"parallels executor" namespace:"parallels"` VirtualBox *VirtualBoxConfig `toml:"virtualbox" json:"virtualbox" group:"virtualbox executor" namespace:"virtualbox"` Cache *CacheConfig `toml:"cache" json:"cache" group:"cache configuration" namespace:"cache"` Machine *DockerMachine `toml:"machine" json:"machine" group:"docker machine provider" namespace:"machine"` }
type Shell ¶
type Shell interface { GetName() string GetSupportedOptions() []string GetFeatures(features *FeaturesInfo) IsDefault() bool GetConfiguration(info ShellScriptInfo) (*ShellConfiguration, error) GenerateScript(scriptType ShellScriptType, info ShellScriptInfo) (string, error) }
type ShellConfiguration ¶ added in v1.3.0
type ShellConfiguration struct { Environment []string DockerCommand []string Command string Arguments []string PassFile bool Extension string }
func GetShellConfiguration ¶ added in v1.3.0
func GetShellConfiguration(info ShellScriptInfo) (*ShellConfiguration, error)
func (*ShellConfiguration) GetCommandWithArguments ¶ added in v1.3.0
func (s *ShellConfiguration) GetCommandWithArguments() []string
func (*ShellConfiguration) String ¶ added in v1.3.0
func (s *ShellConfiguration) String() string
type ShellScriptInfo ¶
type ShellScriptType ¶ added in v1.3.0
type ShellScriptType string
type UpdateBuildRequest ¶
type UpdateBuildRequest struct { Info VersionInfo `json:"info,omitempty"` Token string `json:"token,omitempty"` State BuildState `json:"state,omitempty"` Trace *string `json:"trace,omitempty"` }
type UpdateState ¶
type UpdateState int
const ( UpdateSucceeded UpdateState = iota UpdateNotFound UpdateAbort UpdateFailed UpdateRangeMissmatch )
type UploadState ¶
type UploadState int
const ( UploadSucceeded UploadState = iota UploadTooLarge UploadForbidden UploadFailed )
type VerifyRunnerRequest ¶
type VerifyRunnerRequest struct {
Token string `json:"token,omitempty"`
}
type VersionInfo ¶
type VersionInfo struct { Name string `json:"name,omitempty"` Version string `json:"version,omitempty"` Revision string `json:"revision,omitempty"` Platform string `json:"platform,omitempty"` Architecture string `json:"architecture,omitempty"` Executor string `json:"executor,omitempty"` Features FeaturesInfo `json:"features"` }
type VirtualBoxConfig ¶
Click to show internal directories.
Click to hide internal directories.