Documentation
¶
Index ¶
- func IsForbidden(err error) bool
- func IsNotFound(err error) bool
- type APIError
- type Bridge
- type Client
- func (c *Client) CreatePipelineSchedule(description, ref, cron, cronTimezone string, active bool) (*PipelineSchedule, error)
- func (c *Client) CreatePipelineScheduleVariable(scheduleID int, key, value, variableType string) error
- func (c *Client) DeletePipelineSchedule(scheduleID int) error
- func (c *Client) DeletePipelineScheduleVariable(scheduleID int, key string) error
- func (c *Client) GetPipeline(pipelineID int) (*PipelineDetails, error)
- func (c *Client) GetPipelineSchedule(scheduleID int) (*PipelineSchedule, error)
- func (c *Client) ListJobs(w io.Writer, start time.Time) ([]Job, error)
- func (c *Client) ListPipelineBridges(pipelineID int) ([]Bridge, error)
- func (c *Client) ListPipelineSchedules() ([]PipelineSchedule, error)
- func (c *Client) ListSchedulePipelines(scheduleID int, since time.Time) ([]SchedulePipeline, error)
- func (c *Client) TakeOwnershipPipelineSchedule(scheduleID int) (*PipelineSchedule, error)
- func (c *Client) UpdatePipelineSchedule(scheduleID int, description, ref, cron, cronTimezone string, active bool) error
- func (c *Client) UpdatePipelineScheduleVariable(scheduleID int, key, value, variableType string) error
- type Job
- type PipelineDetails
- type PipelineSchedule
- type PipelineScheduleVariable
- type SchedulePipeline
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsForbidden ¶
IsForbidden reports whether the error is a GitLab 403 response.
func IsNotFound ¶
IsNotFound reports whether the error is a GitLab 404 response.
Types ¶
type APIError ¶
APIError is returned for GitLab API responses with a non-success status code, so callers can distinguish e.g. 403 (missing permission) from 404 (not found) and act on it.
type Bridge ¶
type Bridge struct {
Name string `json:"name"`
Status string `json:"status"`
AllowFailure bool `json:"allow_failure"`
DownstreamPipeline *struct {
ID int `json:"id"`
Status string `json:"status"`
WebURL string `json:"web_url"`
} `json:"downstream_pipeline"`
}
Bridge is a job that triggers a downstream (child or multi-project) pipeline.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a GitLab API client
func (*Client) CreatePipelineSchedule ¶
func (c *Client) CreatePipelineSchedule(description, ref, cron, cronTimezone string, active bool) (*PipelineSchedule, error)
CreatePipelineSchedule creates a new pipeline schedule owned by the token's user. Requires the Developer role and access to the (possibly protected) ref.
func (*Client) CreatePipelineScheduleVariable ¶
func (c *Client) CreatePipelineScheduleVariable(scheduleID int, key, value, variableType string) error
CreatePipelineScheduleVariable creates a new variable on a pipeline schedule. GitLab authorizes this with update_pipeline_schedule, which only the schedule owner (or an instance administrator) holds, so this fails with 403 for schedules owned by other users. Ownership is never changed by this call.
func (*Client) DeletePipelineSchedule ¶
DeletePipelineSchedule deletes a pipeline schedule. Unlike updates this only requires the Maintainer role, not schedule ownership.
func (*Client) DeletePipelineScheduleVariable ¶
DeletePipelineScheduleVariable deletes a variable from a pipeline schedule. Like DeletePipelineSchedule this only requires the Maintainer role, not schedule ownership.
func (*Client) GetPipeline ¶
func (c *Client) GetPipeline(pipelineID int) (*PipelineDetails, error)
GetPipeline retrieves a single pipeline including its detailed status.
func (*Client) GetPipelineSchedule ¶
func (c *Client) GetPipelineSchedule(scheduleID int) (*PipelineSchedule, error)
GetPipelineSchedule retrieves a single pipeline schedule including its variables. Reading the variables of a schedule owned by another user works with the Maintainer role or above and does not require taking ownership; for callers below Maintainer that do not own the schedule, GitLab omits the variables field and Variables is nil.
func (*Client) ListPipelineBridges ¶
ListPipelineBridges retrieves the trigger jobs of a pipeline with their downstream pipelines. Failures of downstream pipelines do not appear in the pipeline's own jobs list.
func (*Client) ListPipelineSchedules ¶
func (c *Client) ListPipelineSchedules() ([]PipelineSchedule, error)
ListPipelineSchedules retrieves all pipeline schedules of the project. The list endpoint does not include variables; use GetPipelineSchedule for a single schedule with its variables.
func (*Client) ListSchedulePipelines ¶
ListSchedulePipelines retrieves the pipelines triggered by a schedule that were created at or after since, oldest first. A zero since returns all of them. The endpoint has no date filter and no documented order, so every page is fetched and filtered here.
func (*Client) TakeOwnershipPipelineSchedule ¶
func (c *Client) TakeOwnershipPipelineSchedule(scheduleID int) (*PipelineSchedule, error)
TakeOwnershipPipelineSchedule makes the token's user the owner of the schedule and returns the updated schedule. Requires the Maintainer role. This is one-way: GitLab has no way to assign ownership to another user, so the previous owner can only get the schedule back by taking ownership themselves. From this call on, the schedule runs with the new owner's permissions.
func (*Client) UpdatePipelineSchedule ¶
func (c *Client) UpdatePipelineSchedule(scheduleID int, description, ref, cron, cronTimezone string, active bool) error
UpdatePipelineSchedule updates the schedule's fields. Like the variable modification calls it requires the schedule owner's token (or instance admin) and returns 403 otherwise; ownership is never changed by this call.
func (*Client) UpdatePipelineScheduleVariable ¶
func (c *Client) UpdatePipelineScheduleVariable(scheduleID int, key, value, variableType string) error
UpdatePipelineScheduleVariable updates the value of an existing pipeline schedule variable. Like CreatePipelineScheduleVariable it requires the schedule owner's token (or instance admin) and returns 403 otherwise; ownership is never changed by this call. Returns 404 if the variable does not exist on the schedule.
type Job ¶
type Job struct {
ID int `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
Duration float64 `json:"duration"`
Pipeline struct {
ID int `json:"id"`
} `json:"pipeline"`
Branch string `json:"ref"`
URL string `json:"web_url"`
Runner *struct {
ID int `json:"id"`
Description string `json:"description"`
} `json:"runner,omitempty"`
}
Job represents a GitLab CI job
type PipelineDetails ¶
type PipelineDetails struct {
ID int `json:"id"`
Status string `json:"status"`
// DetailedStatus.Label is what the UI shows, e.g. "passed with warnings"
// for a pipeline whose status is success but an allowed-to-fail job failed.
DetailedStatus struct {
Label string `json:"label"`
} `json:"detailed_status"`
}
PipelineDetails holds the fields of a single pipeline that its list representation lacks.
type PipelineSchedule ¶
type PipelineSchedule struct {
ID int `json:"id"`
Description string `json:"description"`
Ref string `json:"ref"`
Cron string `json:"cron"`
CronTimezone string `json:"cron_timezone"`
Active bool `json:"active"`
NextRunAt time.Time `json:"next_run_at"`
Owner struct {
Username string `json:"username"`
Name string `json:"name"`
} `json:"owner"`
Variables []PipelineScheduleVariable `json:"variables"`
}
PipelineSchedule represents a GitLab pipeline schedule. Variables are only populated by GetPipelineSchedule, and only when the caller has the Maintainer role or above (or owns the schedule); GitLab omits the field otherwise, which is reflected here as a nil slice.
type PipelineScheduleVariable ¶
type PipelineScheduleVariable struct {
Key string `json:"key"`
VariableType string `json:"variable_type"`
Value string `json:"value"`
Raw bool `json:"raw"`
}
PipelineScheduleVariable represents a variable of a pipeline schedule.
type SchedulePipeline ¶
type SchedulePipeline struct {
ID int `json:"id"`
Status string `json:"status"`
Source string `json:"source"`
Ref string `json:"ref"`
SHA string `json:"sha"`
WebURL string `json:"web_url"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SchedulePipeline is a pipeline triggered by a pipeline schedule.