gitlab

package
v0.0.0-...-70d846f Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsForbidden

func IsForbidden(err error) bool

IsForbidden reports whether the error is a GitLab 403 response.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether the error is a GitLab 404 response.

Types

type APIError

type APIError struct {
	StatusCode int
	Body       string
}

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.

func (*APIError) Error

func (e *APIError) Error() string

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 NewClient

func NewClient(endpoint, token, projectID string) *Client

NewClient creates a new 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

func (c *Client) DeletePipelineSchedule(scheduleID int) error

DeletePipelineSchedule deletes a pipeline schedule. Unlike updates this only requires the Maintainer role, not schedule ownership.

func (*Client) DeletePipelineScheduleVariable

func (c *Client) DeletePipelineScheduleVariable(scheduleID int, key string) error

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) ListJobs

func (c *Client) ListJobs(w io.Writer, start time.Time) ([]Job, error)

ListJobs retrieves all jobs for a project within the given date range

func (*Client) ListPipelineBridges

func (c *Client) ListPipelineBridges(pipelineID int) ([]Bridge, error)

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

func (c *Client) ListSchedulePipelines(scheduleID int, since time.Time) ([]SchedulePipeline, error)

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.

Jump to

Keyboard shortcuts

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