Documentation ¶
Index ¶
- Constants
- Variables
- func Add(agents ...Agent)
- type Agent
- func (a *Agent) CreateContainer(vol string, image string, cmd string, env []string, workdir string) (string, error)
- func (a *Agent) CreateVolume() (string, error)
- func (a *Agent) Filepath(paths ...string) string
- func (a *Agent) Free()
- func (a *Agent) IsReady() bool
- func (a *Agent) ReadFile(container string, file string) ([]byte, error)
- func (a *Agent) RemoveContainer(id string) error
- func (a *Agent) RemoveVolume(name string) error
- func (a *Agent) SavePath(container string, path string, file string) error
- func (a *Agent) StartContainer(container string, stdio func(string)) (int, error)
- func (a *Agent) WriteFile(container string, path string, buf []byte, mode int64) error
- type ConsoleOutput
- type Pipeline
- func (p *Pipeline) BeginPipeline(start time.Time, agent string)
- func (p *Pipeline) BeginStage(stage int)
- func (p *Pipeline) Clone() (*model.Commit, error)
- func (p *Pipeline) CommitFound(commit *model.Commit)
- func (p *Pipeline) Container(image string, cmd string, workdir string, stdio func(string)) (int, error)
- func (p *Pipeline) Destroy()
- func (p *Pipeline) Execute() error
- func (p *Pipeline) ExecuteStage(stageId int, stage *pipelinefile.Stage) error
- func (p *Pipeline) FinishPipeline(status string, duration time.Duration)
- func (p *Pipeline) FinishStage(stage int, status string, duration time.Duration)
- func (p *Pipeline) GetPipelinefile() (*pipelinefile.Definition, error)
- func (p *Pipeline) HeadRef() (string, error)
- func (p *Pipeline) Log(stage int, v ...interface{})
- func (p *Pipeline) LogTerminal(stage int, v ...interface{})
- func (p *Pipeline) PublishPipeline()
- func (p *Pipeline) ReadFile(path string) ([]byte, error)
- func (p *Pipeline) SavePath(path string, local string) error
- func (p *Pipeline) SetArtifactsDir(dir string)
- func (p *Pipeline) SetBuild(build *model.Build)
- func (p *Pipeline) SetProject(project *model.Project)
Constants ¶
const ( UID = 1000 GID = 1000 MOUNTPOINT = "/mnt" WORKDIR = MOUNTPOINT + "/work" )
const ( PIPELINEFILE = "Pipelinefile" STAGE_IMAGE = "alpine:latest" KEY_PATH = "/tmp/id_rsa" KEY_PERMISSIONS = 0600 // scm stage definitions STAGE_SCM_ID = 0 STAGE_SCM_NAME = "Clone" // internal environment variables CI_BUILDNR = "CI_BUILDNR" CI_AGENT = "CI_AGENT" CI_COMMIT_REF = "CI_COMMIT_REF" CI_BRANCH = "CI_BRANCH" )
const ( // scm commands SCM_CLONE = "clone" SCM_HEAD_REF = "head" // scm compare return codes SCM_RET_SUCCESS = 0 SCM_RET_INVALID_BRANCH = 1 )
const (
DOCKER_SOCKET = "/var/run/docker.sock"
)
const (
DOCKER_TIMEOUT = 250 * time.Millisecond
)
const (
EVENT_STREAM_BUFFER = 128
)
Variables ¶
var ( ErrNoContainer = errors.New("no container available") ErrNoAgent = errors.New("no agent available") ErrAlreadyExecuted = errors.New("pipeline was already executed") ErrInvalidBranch = errors.New("branch does not exist") ErrNoProject = errors.New("no project set") )
errors
Functions ¶
Types ¶
type Agent ¶
type Agent struct { // from config file Name string `yaml:"name,omitempty" json:"name"` Endpoint string `yaml:"endpoint,omitempty" json:"endpoint"` Concurrent int `yaml:"concurrent,omitempty" json:"concurrent"` // public runtime variables BuildCount int `json:"build_count" yaml:"-"` // contains filtered or unexported fields }
func (*Agent) CreateContainer ¶
func (*Agent) RemoveContainer ¶
Removes a container with the given ID from the build agent.
func (*Agent) RemoveVolume ¶
Deletes the given volume by its name.
func (*Agent) StartContainer ¶
Executes a command on the build agent, while using the given volume and image.
type ConsoleOutput ¶
type ConsoleOutput struct { // public members Callback func(string) // contains filtered or unexported fields }
type Pipeline ¶
type Pipeline struct { // public variables Agent *Agent Volume string Containers []string StartTime time.Time Env map[string]string Events chan interface{} // contains filtered or unexported fields }
func CreatePipeline ¶
Creates a new pipeline on a free agent.
func (*Pipeline) BeginPipeline ¶
Inform about begining a pipeline.
func (*Pipeline) CommitFound ¶
Publishes the commit details.
func (*Pipeline) Container ¶
func (p *Pipeline) Container(image string, cmd string, workdir string, stdio func(string)) (int, error)
Executes a command in the given image on this pipeline.
func (*Pipeline) Execute ¶
Executes the give project on this pipeline. This is a oneshot action. The pipeline is toren down on success or error.
func (*Pipeline) ExecuteStage ¶
func (p *Pipeline) ExecuteStage(stageId int, stage *pipelinefile.Stage) error
Executes the given stage on this Pipieline.
func (*Pipeline) FinishPipeline ¶
Inform about the end of a pipeline.
func (*Pipeline) FinishStage ¶
Finishes the given stage
func (*Pipeline) GetPipelinefile ¶
func (p *Pipeline) GetPipelinefile() (*pipelinefile.Definition, error)
Downloads and parses the pipeline defition from the working copy.
func (*Pipeline) LogTerminal ¶
Appends a terminal log line to a stage.
func (*Pipeline) PublishPipeline ¶
func (p *Pipeline) PublishPipeline()
Publishes all information about the Pipeline definition to the event stream.
func (*Pipeline) ReadFile ¶
Read a file from the pipeline. At least on container has to be executed.
func (*Pipeline) SavePath ¶
Saves a whole path from the pipeline as gzipped tar archive. At least on container has to be executed.
func (*Pipeline) SetArtifactsDir ¶
Sets the local directory where artifacts are stored.
func (*Pipeline) SetProject ¶
Assigns a project to this pipeline.