Documentation
¶
Overview ¶
Package gitlab provides a GitLab CI API client implementing the external.TestRunner interface. It supports triggering pipelines, polling pipeline status, and retrieving job logs.
GitLab API documentation: https://docs.gitlab.com/ee/api/pipelines.html
Authentication uses a GitLab Personal Access Token (PAT) or Project Access Token. The token must have 'api' scope for pipeline operations.
All API calls use exponential backoff retries for transient failures.
Index ¶
- type Client
- func (c *Client) Cancel(ctx context.Context, runID string) error
- func (c *Client) CancelPipeline(ctx context.Context, projectID, pipelineID string) error
- func (c *Client) GetLogs(ctx context.Context, runID string) (string, error)
- func (c *Client) GetLogsForPipeline(ctx context.Context, projectID, pipelineID string) (string, error)
- func (c *Client) GetStatus(ctx context.Context, runID string) (external.TestStatus, error)
- func (c *Client) GetStatusForPipeline(ctx context.Context, projectID, pipelineID string) (external.TestStatus, error)
- func (c *Client) TriggerTest(ctx context.Context, config external.TestConfig) (*external.TestRun, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a GitLab CI API client implementing external.TestRunner.
func NewClient ¶
func NewClient(config external.ProviderConfig) (*Client, error)
NewClient creates a new GitLab client with the given configuration. The token should be a GitLab PAT with 'api' scope. Returns an error if the configuration is invalid.
func (*Client) CancelPipeline ¶
CancelPipeline attempts to cancel a specific GitLab pipeline.
func (*Client) GetLogsForPipeline ¶
func (c *Client) GetLogsForPipeline(ctx context.Context, projectID, pipelineID string) (string, error)
GetLogsForPipeline retrieves the logs for a specific pipeline. Note: GitLab returns logs per-job, not per-pipeline, so this returns a web UI link.
func (*Client) GetStatus ¶
GetStatus polls the status of a GitLab CI pipeline. Returns the current pipeline status as a TestStatus.
func (*Client) GetStatusForPipeline ¶
func (c *Client) GetStatusForPipeline(ctx context.Context, projectID, pipelineID string) (external.TestStatus, error)
GetStatusForPipeline polls the status of a specific GitLab pipeline. This is a helper method that includes the project ID.
func (*Client) TriggerTest ¶
func (c *Client) TriggerTest(ctx context.Context, config external.TestConfig) (*external.TestRun, error)
TriggerTest triggers a GitLab CI pipeline for the given ref. The JobName is interpreted as the project ID or path (URL-encoded). Parameters are passed as pipeline variables. The Ref specifies which branch/tag/SHA to run the pipeline against. Returns a TestRun with the pipeline ID and metadata.