Skip to main content

prefect_gitlab.credentials

Module used to enable authenticated interactions with GitLab

Classes

GitLabCredentials

Store a GitLab personal access token to interact with private GitLab repositories. Attributes:
  • token: The personal access token to authenticate with GitLab.
  • url: URL to self-hosted GitLab instances.
Examples: Load stored GitLab credentials:
from prefect_gitlab import GitLabCredentials
gitlab_credentials_block = GitLabCredentials.load("BLOCK_NAME")
Methods:

format_git_credentials

format_git_credentials(self, url: str) -> str
Format and return the full git URL with GitLab credentials embedded. Handles both personal access tokens and deploy tokens correctly:
  • Personal access tokens: prefixed with “oauth2:”
  • Deploy tokens (username:token format): used as-is
  • Already prefixed tokens: not double-prefixed
Args: Returns:
  • Complete URL with credentials embedded
Raises:
  • ValueError: If token is not configured

get_client

get_client(self) -> Gitlab
Gets an authenticated GitLab client. Returns:
  • An authenticated GitLab client.