stouputils.continuous_delivery.gitlab module#
This module contains utilities for continuous delivery on GitLab.
upload_to_gitlab: Upload the project to GitLab using the credentials and the configuration (make a release and upload the assets, handle existing tag, generate changelog, etc.)
- validate_gitlab_credentials(
- credentials: dict[str, dict[str, str]],
- gitlab_url: str,
Get and validate GitLab credentials.
- Parameters:
credentials – Credentials dictionary with ‘gitlab’ key containing ‘api_key’
gitlab_url – Default GitLab instance URL
- Returns:
(gitlab_url, headers dict)
- Return type:
tuple
- Raises:
ValueError – If required keys are missing
- validate_gitlab_config(
- gitlab_config: dict[str, Any],
Validate GitLab configuration.
- Parameters:
gitlab_config – Configuration dictionary
- Returns:
(project_path, version, build_folder, endswith list)
- Return type:
tuple
- Raises:
ValueError – If required keys are missing
- build_gitlab_config(
- gitlab_url: str,
- headers: dict[str, str],
- project_path: str,
- version: str,
- build_folder: str,
- endswith: list[str],
Build a PlatformConfig for GitLab.
- Parameters:
gitlab_url – GitLab instance URL
headers – HTTP headers with authorization
project_path – Full project path (e.g., “namespace/project”)
version – Version to release
build_folder – Path to build assets
endswith – File suffixes to upload
- Returns:
Configuration for GitLab release
- Return type:
- delete_gitlab_release(
- config: PlatformConfig,
Delete existing GitLab release for the configured version.
- delete_gitlab_tag(
- config: PlatformConfig,
Delete existing GitLab tag for the configured version.
- get_gitlab_commit_date(
- commit: dict[str, Any],
Extract date from a GitLab commit response.
- extract_gitlab_commit_data(
- commits: list[dict[str, Any]],
Extract (sha, message) tuples from GitLab commits.
- create_gitlab_tag(
- config: PlatformConfig,
Create a new tag on GitLab.
- create_gitlab_release(
- config: PlatformConfig,
- changelog: str,
Create a new GitLab release.
- Parameters:
config – Platform configuration
changelog – Changelog text for the release description
- upload_gitlab_assets(
- config: PlatformConfig,
Upload release assets to GitLab via Package Registry.
- Parameters:
config – Platform configuration
- upload_to_gitlab(
- credentials: dict[str, Any],
- gitlab_config: dict[str, Any],
- gitlab_url: str = 'https://gitlab.com',
Upload the project to GitLab using the credentials and the configuration.
- Parameters:
credentials – Credentials for the GitLab API
gitlab_config – Configuration for the GitLab project
gitlab_url – GitLab instance URL (default: https://gitlab.com)
- Returns:
Generated changelog text
- Return type:
str
Examples:
> upload_to_gitlab( credentials={ "gitlab": { "api_key": "glpat-...", } }, gitlab_config={ "project_path": "DataScience/chestia", "version": "1.0.0", "build_folder": "dist", "endswith": [".tar.gz", ".whl"] }, gitlab_url="https://gitlab.example.com" )