gitlab

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

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

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

func (c *Client) Cancel(ctx context.Context, runID string) error

Cancel attempts to cancel a running pipeline.

func (*Client) CancelPipeline

func (c *Client) CancelPipeline(ctx context.Context, projectID, pipelineID string) error

CancelPipeline attempts to cancel a specific GitLab pipeline.

func (*Client) GetLogs

func (c *Client) GetLogs(ctx context.Context, runID string) (string, error)

GetLogs retrieves the logs for a 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

func (c *Client) GetStatus(ctx context.Context, runID string) (external.TestStatus, error)

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.

Jump to

Keyboard shortcuts

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