Search code examples
apigithubgitlabmirrormirroring

How can I change the mirroring settings in Gitlab over the API?


I want to change the Gitlab mirroring settings for each of my repositories. Is it possible to do this over the Gitlab API?

The options the Gitlab WebUi allows, are the following: enter image description here

How can I change them via the API?

Remark: This is not the same question as "How can I tell Gitlab to mirror my Github repositories over the API?" as there my question was how to start the mirroring, here I want to know how I can change the mirroring settings.


Solution

  • On https://docs.gitlab.com/ee/api/projects.html#edit-project there are several parameters to configure the pull mirroring:

    > mirror
    > mirror_user_id
    > mirror_trigger_builds
    > only_mirror_protected_branches
    > mirror_overwrites_diverged_branches
    

    Note: If your HTTP repository is not publicly accessible, add authentication information to the URL: https://username:password@gitlab.company.com/group/project.git where password is a public access key with the api scope enabled

    Notice that Push mirroring is not yet implemented: https://gitlab.com/gitlab-org/gitlab-ee/issues/7599