Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# semantic_release.hvcs.gitlab module

Helper code for interacting with a Gitlab remote VCS

class semantic_release.hvcs.gitlab.Gitlab(remote_url: str, *, hvcs_domain: str | None = None, token: str | None = None, allow_insecure: bool = False, **_kwargs: Any)

  Bases: `RemoteHvcsBase`

  Gitlab HVCS interface for interacting with Gitlab repositories

  DEFAULT_DOMAIN = 'gitlab.com'
  DEFAULT_ENV_TOKEN_NAME = 'GITLAB_TOKEN'
  OFFICIAL_NAME = 'GitLab'
  commit_hash_url(commit_hash: str) → str
  compare_url(from_rev: str, to_rev: str) → str
  create_or_update_release(tag: str, release_notes: str, prerelease: bool = False) → str

    Create or update a release for the given tag in a remote VCS.

    Parameters:

      - tag – The tag to create or update the release for

      - release_notes – The changelog description for this version only

      - prerelease – This parameter has no effect in GitLab

    Returns:

      The release id

    Raises:

      - ValueError – If the release could not be created or updated

      - gitlab.exceptions.GitlabAuthenticationError – If the user is not authenticated

      - GitlabUpdateError – If the server cannot perform the request

  create_release(tag: str, release_notes: str, prerelease: bool = False, assets: list[str] | None = None, noop: bool = False) → str

    Create a release in a remote VCS, adding any release notes and assets to it

    Parameters:

      - tag – The tag to create the release for

      - release_notes – The changelog description for this version only

      - prerelease – This parameter has no effect in GitLab

      - assets – A list of paths to files to upload as assets (TODO: not implemented)

      - noop – If True, do not perform any actions, only log intents

    Returns:

      The tag of the release

    Raises:

      GitlabAuthenticationError: If authentication is not correct

    Raises:

      GitlabCreateError: If the server cannot perform the request

  create_release_url(tag: str = '') → str
  edit_release_notes(release: ProjectRelease, release_notes: str) → str

    Update the release notes for a given release.

    Parameters:

      - release – The release object to update

      - release_notes – The new release notes

    Returns:

      The release id

    Raises:

      GitlabAuthenticationError: If authentication is not correct

    Raises:

      GitlabUpdateError: If the server cannot perform the request

  static format_w_official_vcs_name(format_str: str) → str
  get_changelog_context_filters() → tuple[Callable[..., Any], ...]

    Return a list of functions that can be used as filters in a Jinja2 template

    ex. filters to convert text to URLs for issues and commits

  get_release_by_tag(tag: str) → ProjectRelease | None

    Get a release by its tag name.

    Parameters:

      tag – The tag name to get the release for

    Returns:

      gitlab.v4.objects.ProjectRelease or None if not found

    Raises:

      gitlab.exceptions.GitlabAuthenticationError: If the user is not authenticated

  issue_url(issue_num: str | int) → str
  merge_request_url(mr_number: str | int) → str
  property project: GitLabProject
  pull_request_url(pr_number: str | int) → str
  remote_url(use_token: bool = True) → str

    Get the remote url including the token for authentication if requested

  upload_dists(tag: str, dist_glob: str) → int

    Upload built distributions to a release on a remote VCS that supports such uploads